在 SSIS 托管对象模型中使用参数覆盖 [英] using Parameter overrides in SSIS Managed Object Model

查看:26
本文介绍了在 SSIS 托管对象模型中使用参数覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用托管对象模型来执行我的 SSIS 2012 包.

I am using the managed Object Model to execute my SSIS 2012 packages.

我正在尝试使用 PackageInfo.PropertyOverrideParameterSet 来覆盖在 SSIS 2012 中自动公开的连接字符串参数.

I am trying to use PackageInfo.PropertyOverrideParameterSet to override connection string parameters that are automatically exposed in SSIS 2012.

SSIS PackageInfo 类提供了重载的Execute 方法 允许您传入要在运行时覆盖的参数.这似乎是设置连接字符串的绝佳机会.

SSIS PackageInfo class provides an overloaded Execute method that allows you to pass in Parameters you want overridden at run-time. THis seems like a perfect opportunity to set connection strings.

创建PackageInfo.PropertyOverrideParameterSet object 但是您需要指定要覆盖的参数的 PropertyPath.

To create a PackageInfo.PropertyOverrideParameterSet object however you need to specify the PropertyPath of the parameter you intend to override.

需要采用什么格式?

推荐答案

可以使用 PackageInfo.ExecutionValueParameterSet 而不是 PackageInfo.PropertyOverrideParameterSet.ParameterName 用于连接字符串将遵循 CM..ConnectionString 格式(将 替换为您的连接管理器名称).在下面的代码段中,我的连接管理器名为 B540P.KB1).

Setting a connection string can be done using PackageInfo.ExecutionValueParameterSet instead of the PackageInfo.PropertyOverrideParameterSet. The ParameterName for a connection string would follow the format CM.<connectionManagerName>.ConnectionString (replace <connectionManagerName> with your connection manager name). In the snippet below, my connection manager is named B540P.KB1).

PackageInfo.ExecutionValueParameterSet evps = new PackageInfo.ExecutionValueParameterSet();
evps.ParameterName = @"CM.B540P.KB1.ConnectionString";
evps.ParameterValue = @"Data Source=B540P;Initial Catalog=AdventureWorks;Integrated Security=True;Application Name=SSIS-Package1-{19035BA0-C90C-47AA-8AF6-31B025779FF6}B540P.KB1;";
evps.ObjectType = 30;

System.Collections.ObjectModel.Collection<PackageInfo.ExecutionValueParameterSet> parms = new System.Collections.ObjectModel.Collection<PackageInfo.ExecutionValueParameterSet>();
parms.Add(evps);           

pkg.Execute(false, null, parms, null);

可以使用 PackageInfo.PropertyOverrideParameterSet 来设置连接字符串,但我不确定 PropertyPath 将是(有关 PropertyPath 用于 SSIS 变量).

It may be possible to use PackageInfo.PropertyOverrideParameterSet to set the connection string, but I'm not sure what the PropertyPath would be (see SQL Server link below for an example of a PropertyPath for an SSIS variable).

这里有一些关于通过不同方法与 MOM 交互的好信息:

Here's some good information on interacting with MOM via different approaches:

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