Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET connection to MS Access
    primarykey
    data
    text
    <p>I get an error when I am trying to connect to a Microsoft Access DB using VB.NET. I see examples all over the web. My code looks like those examples, however I am getting a build error message stating:</p> <blockquote> <p>Type 'System.Data.OleDb.OleDbConnection' is not defined.</p> </blockquote> <p>I have tried adding some kind of import statement for the <code>system.data.oledb</code>... but that does not seem to work. My code is below. It is a basic connection so I am thinking that I am missing some kind of add in, library, or setting. Any and all help would be greatly appreciated.</p> <pre><code>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;" &amp; _ "Data Source=C:\Users\DMalerman\keyword.accdb;" &amp; _ "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 " &amp; _ "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 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload