Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I'm loading and executing SSIS Package Programatically. I have one Parameter which i want to pass to SSIS Package from my application( My question is: the package doesn't see my parameter at all. how should I pass the Parameter to SSIS Package 2008 R2?

my code is:

Package package = new Package();
           package.Name = "ConfigurationSample";

           Variables vars = package.Variables;

           vars["PackageVar"].Value = "TEST";

           ConnectionManager connectionManagerOleDb = package.Connections.Add("OLEDB");
           connectionManagerOleDb.Name = "SQLConnection";
           connectionManagerOleDb.ConnectionString =
               "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=master;Integrated Security=SSPI;";

           package.EnableConfigurations = true;
           Microsoft.SqlServer.Dts.Runtime.Configuration confg = package.Configurations.Add();

           confg.Name = "PackConfg";
           confg.ConfigurationType = DTSConfigurationType.SqlServer;
           confg.ConfigurationString = ConfigurationString;
           DTSExecResult results = package.Execute();

Thank you in advance
Updated 10-Aug-12 7:50am
[no name] 10-Aug-12 14:36pm

1 solution

Here the issue I believe is setting values to a copy of Package Variables, and never updated to package.
Variables vars = package.Variables;
vars["PackageVar"].Value = "TEST";

now vars is never copied to package.

The ideal way to add variable is :

Variable myVar = package.Variables.Add("PackageVar", false, "User", "Test");

The add method can be defined as :

string name,
bool readOnly,
string nameSpace,
Object val


Type: System.String
The name of the package, task, or container variable to add to the collection.

Type: System.Boolean
A Boolean that indicates whether the variable is read-only or whether the variable can be modified.

Type: System.String
The namespace for the variable. Default value is the User variable namespace. You can also create a namespace to identify variables you create that are used in a certain part of a package. You cannot add variables to the System variable namespace.

Type: System.Object
The design-time value of the variable.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900