System.ArgumentException: 对象不是 ADODB.RecordSet 或 ADODB.Record [英] System.ArgumentException: Object is not an ADODB.RecordSet or an ADODB.Record

查看:27
本文介绍了System.ArgumentException: 对象不是 ADODB.RecordSet 或 ADODB.Record的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码来填充数据表 -

I used the code below to fill a data table -

OleDbDataAdapter oleDA = new OleDbDataAdapter();
DataTable dt = new DataTable();
oleDA.Fill(dt, Dts.Variables["My_Result_Set"].Value); 

我收到错误 -

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Object is not an ADODB.RecordSet or an ADODB.Record.
Parameter name: adodb
   at System.Data.OleDb.OleDbDataAdapter.FillFromADODB(Object data, Object adodb, String srcTable, Boolean multipleResults)
   at System.Data.OleDb.OleDbDataAdapter.Fill(DataTable dataTable, Object ADODBRecordSet)
   at ST_34944nkdfnfkdffk333333.csproj.ScriptMain.Main()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

为什么会出现这个错误?我之前使用过完全相同的代码,它从未给我带来任何问题.

Why do I get this error ? I have used the exact same code before and it never gave me any problems.

推荐答案

当您没有在 SSIS 中连接两个组件时会发生此错误.看图——执行 SQL 任务会生成一个 ADO 记录集,该记录集将由 C# 脚本使用.该 ADO 存储在 SSIS 对象变量(图中未显示)中,并由我在问题中提到的 C# 脚本获取.

This error happens when you have not connected two components in SSIS. See image - The execute SQL task produces an ADO record set which will be consumed by the C# script. That ADO is stored in an SSIS object variable (not shown in image) and is picked up by the C# script which I mentioned in my question.

这篇关于System.ArgumentException: 对象不是 ADODB.RecordSet 或 ADODB.Record的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆