Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (17.6k points)
I have a SSIS kit that I want to transfer parameters too, these parameters must come from a. NET framework (VB or C #) so I was wondering if anyone knows how to do this, or better yet a website with helpful tips on how to do this.

So essentially I want to run a SSIS package from. NET that transfers the parameters of the SSIS package it can use inside.

For example, the SSIS package will use flat file importing into a SQL database but the file name and path might be the parameter passed from the. Net application.

1 Answer

0 votes
by (47.2k points)

Here's how to set variables from code within the package 

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");

    }

Check out Msbi certification training that enables you to master MSBI tools like SSIS, SSRS, and SSAS using SQL Server.  

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 27, 2020 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer
asked Feb 27, 2020 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer

Browse Categories

...