Running the SSIS package from Console/Windows/Web Application


The running SSIS package in Console/Windows/Web Application needs of usage of namespace.

Microsoft.SqlServer.Dts.Runtime.

Go to Solution Explorer of your project?Rightclick and the references

Add reference-->add Microsoft.SqlServer.Dts.Runtime;

Then call the added namespace into your project.

Running the Package in a Console application you need to think in your mind.

Package ->As your running the SSIS package, create a object of package;

Package path ->Path of the package where you have stored.

Application->This object will create an Instance of application.

Package results->we use DTSExecResult this object available in Microsoft.SqlServer.Dts.Runtime which helps to know the the packet is excuted sucess fully or not.

using System;
using Microsoft.SqlServer.Dts.Runtime;

 namespace RunningSSISInConsoleApp
{
    class Program
    {
                         static void Main(string[] args)
      {
      string pkgLocation;
            Package pkg;
            Application app;
            DTSExecResult pkgResults;
pkgLocation = @"C:\Users\dell\Documents\Visual Studio 2008\Projects\Integration Services Project1\Integration Services Project1\package2.dtsx";
            app =new Application();
            pkg = app.LoadPackage(pkgLocation, null);
            pkgResults = pkg.Execute();
            Console.WriteLine(pkgResults.ToString());
Console.ReadLine();
}

 }

}

Source :MSDN Microsoft
 

Ebook Download
View all
Learn
View all