如何在SSIS脚本任务中遍历通用对象 [英] How to loop through a generic object in SSIS Script Task

查看:89
本文介绍了如何在SSIS脚本任务中遍历通用对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通用对象,该对象从SQL进程传递到脚本任务中。该对象本质上将是一个数据表,但是为了从sql进程中获取完整的结果集,我必须将其存储在一个通用对象中。

I have a generic object that is passed into a script task from a SQL Process. The object will essentially be a data table but in order to get the full result set from the sql process i have to store it in a generic object.

所以如果我有:

Object A = Dts.Variables[0];

然后我将如何提取并操纵其值。

How then would I go about extracting and then manipulating its values.

基本上我想做的是:

Object A = Dts.Variables[0];
strin x = A.Column[0].value.tostring();

但这显然行不通。

推荐答案

从Object解析数据表没有错。我已经看到安迪·伦纳德(Andy Leonard)在他的ETL框架上做到了。

There's nothing wrong with parsing a data table from an Object. I've seen Andy Leonard do it on his ETL frameworks.

您在正确的路径上,但看不到整个图片。此代码为变量(大约)分配一个对象然后尝试访问不存在的属性。

You were on the correct path but you weren't seeing the whole picture. This code assigns the an object of type Variable (approximately) to A. You are then attempting to access a property that doesn't exist.

Object A = Dts.Variables[0];

您需要获取变量的 value 。您可以将其作为对A的赋值来完成

Your need to grab the value of the variable. You can either do it as the assignment to A

Object A = Dts.Variables[0].Value;

或者,如果您需要对实际变量进行其他操作,则可以保留当前代码

Or if you needed to do something else with the actual variable, you'd keep your current code assignment of A then access the Value property.

Object A = Dts.Variables[0];
DataTable B = (DataTable) A.Value;
DataRow C = B.Row[0];
string x = C.Column[0].ToString();

上面的datatable / datarow代码是近似的。重要的收获是访问SSIS变量持有的商品,您需要访问对象的Value。

The above code for datatable/datarow is approximate. The important take away is to access the goodies an SSIS variable is holding, you need to access the Value of the object.

这篇关于如何在SSIS脚本任务中遍历通用对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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