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

查看:24
本文介绍了如何循环遍历 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();

但这显然行不通.

推荐答案

从对象解析数据表没有任何问题.我已经看到 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.

您走在正确的道路上,但没有看到全貌.此代码分配类型 变量 的对象(大约)到 A.然后您正在尝试访问不存在的属性.

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];

您需要获取变量的.您可以将其作为对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;

或者,如果您需要对实际变量执行其他操作,您可以保留 A 的当前代码分配,然后访问 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();

上面的数据表/数据行代码是近似的.重要的一点是访问 SSIS 变量保存的好东西,您需要访问对象的值.

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天全站免登陆