1

我的 SSIS 包中有两个脚本任务。第一个将字符串数组保存为包变量:

// In 1st script task:
String[] astrCustNames = new String[cust_count];

/* ...
 * Some code to add strings to array ...
 */

// Add array to a package variable
Dts.Variables["CustomerNames"].Value = astrCustNames;

然后第二个任务应该从变量中提取字符串。过去,我使用表变量来完成此操作。这不适用于字符串数组:

// In 2nd script task:
OleDbDataAdapter ole_da = new OleDbDataAdapter();
// Fill the customer names data table
DataTable dtCustNames = new DataTable();
ole_da.Fill(dtCustNames, Dts.Variables["User::CustomerNames"].Value);

填充数据适配器的调用将导致错误“对象不是 ADODB.RecordSet 或 ADODB.Record”。

.dtsx 包将数据类型列为 DTS:DataType="13"

包中定义的变量的数据类型是“对象”:

// Returns type "Object":
TypeCode cur_type = Dts.Variables["User::CustomerNames"].DataType;

我一直在寻找提取存储在 SSIS 变量中的数组中的字符串的示例,但没有找到。

4

1 回答 1

1

好吧,事实证明这再简单不过了。

只需将值转换为字符串数组:

String[] astrCustNames = (String[])Dts.Variables["User::CustomerNames"].Value;
于 2014-08-26T20:41:21.283 回答