views:

8245

answers:

6

I have a SSIS package that eventually I would like to pass parameters too, these parameters will come from a .NET application (VB or C#) so I was curious if anyone knows of how to do this, or better yet a website with helpful hints on how to do it. So basically I want to execute a SSIS package from .NET passing the SSIS package parameters that it can use within it. For instance, the SSIS package will use flat file importing into a SQL db however the Path and name of the file COULD be the parameter that is passed from the .net application. THANKS!

+11  A: 

Running SSIS package programmatically

Gulzar
A: 

THANK YOU!!! I searched for hours, not sure HOW I missed that site!

Just another quick nod and thanks here! We were having a discussion in the office about remotely calling SSIS packages and my brain said "Hey, I wonder if somebody on StackOverflow would know..." 8^D
Dillie-O
A: 

u find it, please tell me

A: 

The link above only gives a very simple example. Can someone please direct me to an example that passes parameter to the package? Thanks!

+2  A: 

Here is how to set variables in the package from code -

using Microsoft.SqlServer.Dts.Runtime;

private void Execute_Package()
    {           
        string pkgLocation = @"c:\test.dtsx";

        Package pkg;
        Application app;
        DTSExecResult pkgResults;
        Variables vars;

        app = new Application();
        pkg = app.LoadPackage(pkgLocation, null);

        vars = pkg.Variables;
        vars["A_Variable"].Value = "Some value";               

        pkgResults = pkg.Execute(null, vars, null, null, null);

        if (pkgResults == DTSExecResult.Success)
            Console.WriteLine("Package ran successfully");
        else
            Console.WriteLine("Package failed");
    }
CraigS