c# - 使用 SSIS 数据流任务中的脚本组件将对象中的数据提取到 DataTable
问题描述
我正在寻找一种在 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);
任何线索或指导将不胜感激。
解决方案
推荐阅读
- java - 返回当前日期后 num 天的日期值 JAVA
- r - 评估多项式函数
- php - 判断存储日志文件夹中是否存在日志文件
- bean-validation - 如何在 bean 验证中国际化 @Pattern(regexp="(^$|[0-9]{10})")?
- etl - APACHE NIFI vs APACHE AIRFLOW vs APACHE FALCON ? 以下场景中哪个最适合?
- docker - Docker - 容器 IP 地址映射
- json - 如何在 python 中构建配置文件?
- android - Android Studio - 旋转图像时如何避免OutOfMemoryError
- java - 适配器模式和包装
- javascript - 使用客户端 JavaScript 在 FFT 中转换时间序列数据