Thursday 2 January 2014

How to run SSIS package using C# code

Hello friends,


Here again i am going to show you how you can call an ssis package using C# code. as we know we have execute ssis package component to call other package but if you are going to call a set of ssis package and all those package location store in a database , in that case execute package will open different dataflow window to call one after another ssis package. It’s always not good. So we can create a dynamic string with a variable and we can use that variable inside a C# to call number of packages
.
Here is the code (a packge name as calculated columns .dtsx)


using System;

using Microsoft.SqlServer.Dts.Runtime;

namespace RunFromClientAppCS

{

class Program

{

static void Main(string[] args)

{

string pkgLocation;

Package pkg;

Application app;

DTSExecResult pkgResults;

pkgLocation =

@"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" +

@"\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";

app = new Application();

pkg = app.LoadPackage(pkgLocation, null);

pkgResults = pkg.Execute();

Console.WriteLine(pkgResults.ToString());

Console.ReadKey();

}

}


enjoy !!