Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\itweb\Documents\Visual Studio 2010\WebSites\notitiae\databases\notitiae.accdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [tblCounties].* FROM [tblCounties]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim DSCounties As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(DSCounties)
Ok. So I’m using the above code to connect to an access 2007 DB. Now I have to add a linked table pointing to a DB which has user level protection. Research has shown me how to add a username and password to the connection string. Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\itweb\Documents\Visual Studio 2010\WebSites\notitiae\databases\notitiae.accdb; user name=user; password=pwd;"
I also learned that I need to add a reference to the workgroup file, “V:\DATABASE\WORKDIR\diodb.mdw”. my problem is that all the information online referencing workgroup files use an ADODB connection rather than my OleDb connection and jet 4 rather than ACE 12. What’s the syntax for adding the workgroup file? I tried to add an ADODB object to my Visual studio project but VS wouldn't add the reference for ActiveX Data Objects 2.5. That's why I'm using OleDB.