none
Connecting to MDB file on x64 platform RRS feed

  • Question

  • Hi

    In my ado.net/vb.net app how can I connect to an MDB file on Win 7 x64 platform? Would appreciate a short code example.

    Thanks

    Regards

    Thursday, May 10, 2012 1:00 AM

Answers

  • Below is a simple example. Note that the Platform option (Build...Configuration Manager...) must be set to x86. This will force the app to run 32-bit in order to support the Jet OLEDB Provider (which is 32-bit only). If you want to run 64-bit then you would have to use the ACE OLEDB Provider.

            Dim ConnectionString As String
    
            ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=C:\Test Files\db1 XP.mdb"
            Dim AccessConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
            AccessConnection.Open()
    
            Dim da As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [Products]", AccessConnection)
            Dim ds As New DataSet
    
            da.Fill(ds, "Products")
    
            DataGridView1.DataSource = ds.Tables("Products")


    Paul ~~~~ Microsoft MVP (Visual Basic)


    Thursday, May 10, 2012 1:30 PM