Executing and managing packages programmatically
One of the most useful aspects of SSIS programming is executing and managing packages. We can load a package from DTSX file or SQL Server, add or configure logging parameters and other configuration, and execute it. This is a very useful ability because you may want to create a .NET application for managing packages, so you will need to run and manage packages programmatically.
In this recipe, we will save the package from the Working with Data Flow components programmatically recipe and then add logging to it and execute it.
Getting ready
As this recipe is a complement to the previous recipe, just do steps 1 to 17 from previous recipe.
How to do it...
Write the following statements after step 17 of the previous recipe to save the package as a DTSX file:
Application app = new Application(); app.SaveToXml(@"C:\SSIS\Ch14_Programming SSIS\Files\R03_Package.dtsx", pkg, null);
Create an SSIS project and right-click on the SSIS
Packages
folder and add...