如何在脚本任务中访问Object SSIS变量?

时间:2018-07-20 04:40:41

标签: c# ssis

我有类型为 object 的SSIS变量,该变量保存来自 OLE DB源的OLE DB结果集。

对象是博客列表,每个博客都具有属性标题描述。 如何解析SSIS对象变量并遍历每个Blog,然后遍历字段?

编辑

我想阅读脚本任务中的完整结果集。

1 个答案:

答案 0 :(得分:0)

// this gets the data object and sets ti to a data table
            OleDbDataAdapter A = new OleDbDataAdapter();
            System.Data.DataTable dt = new System.Data.DataTable();
            A.Fill(dt, Dts.Variables["User::SSISObjectVariableFromPackage"].Value);

            // for test data
            DataTable sourceTable = dt;

            //Now loop through databale and do your processing



//----------------------------------------------------------------------
//Updated  -- possible solution to fix issue in comments but left original above as that works for most 

//try this version instead, mabye converting the SSIS variable to a C# object first, and not accessing it directly into the A.Fill may resolve your issue in the comments:

Object OBJDataTableValidFieldListFull = Dts.Variables["User::SSISObjectVariableFromPackage"].Value;

    // this gets the data object and sets ti to a data table
                OleDbDataAdapter A = new OleDbDataAdapter();
                System.Data.DataTable dt = new System.Data.DataTable();
                A.Fill(dt, OBJDataTableValidFieldListFull);

                // for test data
                DataTable sourceTable = dt;

                //Now loop through databale and do your processing