Building Packages Programmatically
If you need to create packages dynamically, or to manage and execute Integration Services packages outside the development environment, you can manipulate packages programmatically. In this approach, you have a continuous range of options:
Load and execute an existing package without modification.
Load an existing package, reconfigure it (for example, for a different data source), and execute it.
Create a new package, add and configure components object by object and property by property, save it, and execute it.
You can use the Integration Services object model to write code that creates, configures, and executes packages in any managed programming language. For example, you may want to create metadata-driven packages that configure their connections or their data sources, transformations, and destinations based on the selected data source and its tables and columns.
This section describes and demonstrates how to create and configure a package programmatically line by line. At the less complex end of the range of package programming options, you can simply load and run an existing package without modification as described in Running and Managing Packages Programmatically.
An intermediate option not described here is that of loading an existing package as a template, reconfiguring it (for example, for a different data source), and executing it. You can also use the information in this section to modify the existing objects in a package.
When you use an existing package as a template and modify existing columns in the data flow, you may have to remove existing columns and call the ReinitializeMetaData method of affected components.
CodePlex samples, Integration Services Product Samples, on www.codeplex.com/MSFTISProdSamples