VB.NETを使用してMicrosoftAccessDBに接続しようとすると、エラーが発生します。Web全体に例があります。私のコードはこれらの例のように見えますが、次のようなビルドエラーメッセージが表示されます。
タイプ「System.Data.OleDb.OleDbConnection」は定義されていません。
...に何らかのインポートステートメントを追加しようとしましたsystem.data.oledb
が、うまくいかないようです。私のコードは以下の通りです。これは基本的な接続なので、何らかのアドイン、ライブラリ、または設定が不足していると思います。ありとあらゆる助けをいただければ幸いです。
Public Function TestMain(ByVal args() As Object) As Object
' Connection String to MS Access DB
Dim connectStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Users\DMalerman\keyword.accdb;" & _
"Persist Security Info=False;"
MsgBox(connectStr)
' Create connection to the db
Using connection As New System.Data.OleDb.OleDbConnection(connectStr)
' Create the SQL Query
Dim readQuery As String = "Select KeywordDriver.ScriptName from KeywordDriver " & _
"where KeywordDriver.Keyword = test"
Dim queryCommand As New System.Data.OleDb.OleDbCommand(readQuery, connection)
'Open the Connection
connection.Open()
' Query the Database
Dim dbReader As System.Data.OleDb.OleDbDataReader = queryCommand.ExecuteReader()
' Loop until there is nothing left to read
While dbReader.Read()
Dim sKeyword As String = ""
sKeyword = dbReader.GetString(0)
MsgBox(sKeyword)
End While
' Close the Reader
dbReader.Close()
End Using
Return Nothing
End Function