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)
You should be using OleDbDataAdapter
instead of SqlDataAdapter
. It's trying to read the connection string as a SQL Server connection string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With