将变量发送到SSIS Package 2008 [英] send Variables to SSIS Package 2008

查看:89
本文介绍了将变量发送到SSIS Package 2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在以编程方式加载和执行SSIS程序包.我有一个参数,我想从我的应用程序(asp.net)传递给SSIS包.我的问题是:程序包根本看不到我的参数.如何将参数传递给SSIS Package 2008 R2?

我的代码是:

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:

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

推荐答案

在这里,我认为这个问题是将值设置为Package Variables的副本,而从未更新为package.
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";


现在vars永远不会复制到包中.

添加变量的理想方法是:

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

add方法可以定义为:

添加(
字符串名称,
bool readOnly,
字符串nameSpace,
对象val
)

参数

名称
类型:System.String
要添加到集合中的包,任务或容器变量的名称.

readOnly
类型:System.Boolean
一个布尔值,指示变量是只读的还是可以修改的变量.

nameSpace
类型:System.String
变量的名称空间.默认值为用户变量名称空间.您还可以创建一个名称空间,以标识您在包的某些部分中使用的创建的变量.您不能将变量添加到系统变量名称空间.

val
类型:System.Object
变量的设计时值.


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.


这篇关于将变量发送到SSIS Package 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆