1 Previous Next 

VS.Net Open database in 64 bit OS


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

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en



    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



1 Previous Next