This article deals with executing SSIS package stored in a file system using C# code.
There are many ways to execute an SSIS package which Karthik had already covered in the article
Apart from those today we will discuss on how we can execute an SSIS package stored in a file system using c# programming.
Scenario is first we will build a SSIS package. Then we will create a console application to execute using c#.
So lets start ....
1. First create a SSIS package .. Please refer to
http://www.dotnetfunda.com/articles/article1214-conditional-split-in-ssis-.aspx and create an SSIS package which reads a file and splits the data into two files there by separating all male students into one file and all female students into another.
2. Now once that is done we will create a console application to execute this SSIS package programmatically.
Start your Visual Studio and Add a console application, Right click on the References and add a reference to Microsoft.SQLServer.ManagedDTS.dll
3. Now lets add code to the console app as shown below.
4. On Executing the console app, the code executes the package and returns the result on the consolde window.
5. Incase we have any Configuration files or Variables used in the SSIS package we need to add few more lines of code to pass the same. Since we didnot have any configuration file or variables used in the SSIS package, it is much easier on our part.
Incase you have any configuration file defined for a package you can load the configuration details using the code below.
And in case you need to pass any variables you can do the same using the below lines of code.
Variables variables = package.Variables;
variables["MyPackageVariable"].Value = "DotNetFunda";
Isn't it so simple...
Hope you all would like this article. Do comment on this ...