0

我正在寻找一种在 SSIS 数据流任务中使用脚本组件(作为源)来输出从对象数据类型生成的表的方法。以下是我尝试过的

我的脚本组件属性

在此处输入图像描述

我的脚本

public class ScriptMain : UserComponent
{

    public override void CreateNewOutputRows()
    {
        /*
          Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
          For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */

        // Set up the DataAdapter to extract the data, and the DataTable object to capture those results
        OleDbDataAdapter da = new OleDbDataAdapter();
        DataTable dt = new DataTable();

        // Extract the data from the object variable into the table

        da.Fill(dt, Variables.resultSet);

        // Since we know the column metadata at design time, we simply need to iterate over each row in
        //  the DataTable, creating a new row in our Data Flow buffer for each

        foreach (DataRow dr in dt.Rows)
        {
            // Create a new, empty row in the output buffer

            OutputDataBuffer.AddRow();

            // Now populate the columns
            OutputDataBuffer.tablename = Convert.ToString(dr["table_name"]);
            OutputDataBuffer.colname = Convert.ToString(dr["column_name"]);
            OutputDataBuffer.jsonattr = Convert.ToString(dr["json_attribute"]);
            OutputDataBuffer.datatype = Convert.ToString(dr["data_type"]);
        }

    }

}

我面临的问题

当我运行包时出现以下错误,我尝试了一些我看到的相关问题的修复,但没有一个有效

在此处输入图像描述

我怀疑问题出在我脚本的以下部分(为什么因为当我删除它并运行它时没有抛出任何错误)

// Extract the data from the object variable into the table

da.Fill(dt, Variables.resultSet);

任何线索或指导将不胜感激。

4

0 回答 0