私のセットアップ - .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);