Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SSIS脚本组件关闭读取器_C#_Ssis_Script Component - Fatal编程技术网

C# SSIS脚本组件关闭读取器

C# SSIS脚本组件关闭读取器,c#,ssis,script-component,C#,Ssis,Script Component,我的SSIS脚本组件有问题。在我的CreateNewOutputRows方法得到它之前,我的阅读器似乎已经关闭了。有人能帮我吗 OdbcConnection odbcConn; OdbcCommand odbcCmd; OdbcDataReader odbcReader; public override void PreExecute() { base.PreExecute(); using (odbcConn = new OdbcConnection(this.Connect

我的SSIS脚本组件有问题。在我的CreateNewOutputRows方法得到它之前,我的阅读器似乎已经关闭了。有人能帮我吗

OdbcConnection odbcConn;
OdbcCommand odbcCmd;
OdbcDataReader odbcReader;

public override void PreExecute()
{
    base.PreExecute();
    using (odbcConn = new OdbcConnection(this.Connections.InformixODBC.ConnectionString))
    {
        odbcConn.Open();
        string cmdText = Variables.INFORMIXQUERY;
        cmdText = cmdText.Replace("{{START_DATETIME}}", "'" + Variables.STARTDATETIME + "'");
        cmdText = cmdText.Replace("{{END_DATETIME}}", "'" + Variables.ENDDATETIME + "'");

        odbcCmd = new OdbcCommand(cmdText, odbcConn);
        odbcReader = odbcCmd.ExecuteReader();
    }
}
这就是我目前设置阅读器的方式。我通过了,它似乎退出了PreExecute方法,进入了CreateNewOutputRows方法,但我无法执行任何AddRow调用,因为读卡器已关闭


任何帮助都将不胜感激。谢谢

读卡器是通过您的连接连接的。一旦using语句超出范围,连接就被处理掉,瞧,您的阅读器现在与源断开了连接

相反,您需要在预执行中将结果加载到DataSet/DataTable中,然后随时枚举结果

或者将预执行逻辑推送到CreateNewOutputRows方法中

用于使用ResultSet和填充数据集的MSDN链接