读取 SSIS 脚本组件源中的对象变量值 [英] Reading object variable values in SSIS script component source
问题描述
是否可以读取 SSIS 脚本组件源中的对象变量值?
Is it possible to read object variable values in SSIS script component source?
我有一个对象类型的变量,它包含使用 SQL 脚本任务填充的表中的记录.
I have a variable, of type Object, which contains records from table populated by using a SQL Script Task.
我已经使用了这个脚本任务并且通过使用下面的代码可以完美地工作
I have used this Script Task and it's working perfectly by using below code
oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
以这种方式,vTableRowsObj
是对象变量.
in this way where vTableRowsObj
is object variable .
我想在 SSIS 脚本组件中读取此对象,以便我可以直接将脚本组件的输出提供给目标表.
I want to read this object in an SSIS script component so that I can directly give the output from script component to the destination table.
最终目标是我计划创建更多的对象变量,并简单地通过读取这些对象,将输出从脚本组件提供给目标表.
The end goal is that I am planning to create more object variables and simply by reading these objects, give the output to destination tables from script component.
推荐答案
我遇到了类似的问题.
这里有一些参考链接,我的代码如下,用于 ID 和名称的简单输出.
I had a similar issue.
Here's some links to reference and my code is below for simple output for ID and Name.
http://agilebi.com/jwelch/2007/03/22/writing-a-resultset-to-a-flat-file/
http://www.ssistalk.com/2007/04/04/ssis-using-a-script-component-as-a-source/
http://consultingblogs.emc.com/jamiethomson/archive/2006/01/04/SSIS_3A00_-Recordsets-instead-of-raw-files.aspx
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Xml;
using System.Data.OleDb;
public override void CreateNewOutputRows()
{
DataTable dt = new DataTable();
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.Fill(dt, this.Variables.ObjectVariable);
foreach (DataRow row in dt.Rows)
{
Output0Buffer.AddRow();
Output0Buffer.ID = Convert.ToInt32(row.ItemArray[0]);
Output0Buffer.Name = row.ItemArray[1].ToString();
}
}
这篇关于读取 SSIS 脚本组件源中的对象变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!