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

I'm loading and executing SSIS Package Programatically. I have one Parameter which i want to pass to SSIS Package from my application(asp.net). 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:

C#
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
Posted
Updated 10-Aug-12 7:50am
v2
Comments
[no name] 10-Aug-12 14:36pm    
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/ec510c66-a9e0-4710-b95c-5a86a29145f5/

1 solution

Here the issue I believe is setting values to a copy of Package Variables, and never updated to package.
C#
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 :

Add(
string name,
bool readOnly,
string nameSpace,
Object val
)

Parameters

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

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

nameSpace
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.

val
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