Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Keyword not supported: provider" connecting to Access db on VS08

I'm trying to connect a DataGridView to an access 2000 database on Visual Studio 2008.

I keep getting the "Keyword not supported: provider" error, as I'm fairly new to windows development on .Net I don't know if I'm doing it right.

Here's the code:

Try
    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Contingencia\Carga_sap.mdb;User Id=admin;Password=;"
    Dim strQuery As String = "SELECT ..."
    Dim dataAdapter = New SqlDataAdapter(strQuery, strConn)
    Dim table As New DataTable()
    table.Locale = System.Globalization.CultureInfo.InvariantCulture
    dataAdapter.Fill(table)
    bsLista.DataSource = table
    GridListado.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader)
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try

Thanks in advance

EDIT: I just needed to change the Data Adapter to OLE:

Dim dataAdapter = New OleDbDataAdapter(strQuery, strConn)
like image 728
Carlos Trejo Avatar asked Apr 05 '11 19:04

Carlos Trejo


1 Answers

You should be using OleDbDataAdapter instead of SqlDataAdapter. It's trying to read the connection string as a SQL Server connection string.

like image 70
Joe Enos Avatar answered Oct 16 '22 06:10

Joe Enos