我的设置 - .NET 3.5 和 Visual Studio 2008。我有 c# 代码(在 ssis 中,但不用担心 ssis)。我希望能够在我的代码中使用 ADODB。因此,我添加了对 ADODB 的引用。我从 COM 选项卡中选择了 Microsoft ActiveX Data Objects 2.8 Library。然后,我添加了使用 ADODB 作为我的导入。
示例步骤在这里 -
http://www.c-sharpcorner.com/uploadfile/ptailor/adodbservice12062005002501am/adodbservice.aspx
但是,在运行项目后,我收到一个错误,并且我还看到引用列表中缺少引用。我发誓它在我添加后就在那里。我该如何解决这个问题?
错误-
System.IO.FileNotFoundException: Could not load file or assembly 'Interop.ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Interop.ADODB, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null'
at ST_39348fjejencuw92092828303554.csproj.ScriptMain.Main()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
--- 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()
需要这个问题 -
我试图使用下面的代码来获取 ADO 记录集中的行数。当我尝试使用代码时,我不断收到错误“找不到类型或命名空间名称'ADODB'”。
ADODB.Recordset result = (ADODB.Recordset)Dts.Variables["RESULT_SET"].Value;
int rowCount = result.RecordCount;
MessageBox.Show("rowCount = " + rowCount);