If you try and open an access database on a
64bit os you will get the following error. System.InvalidOperationException:
The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
To prevent this open My Project -> compile -> advanced compiler options
and set the target cpu to x86.
Otherwise get the new redistributable
Otherwise get the new redistributable
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As OleDbConnection
Dim strConn As String
Dim da As OleDbDataAdapter
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = c:\Northwind.mdb;"
conn = New OleDbConnection(strConn)
ds = New DataSet
da = New OleDbDataAdapter("Select * from Products", conn)
Try
da.Fill(ds, "Products")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
DataGridView1.DataSource = ds.Tables("Products")
End Sub
0 comments:
Post a Comment