Unrecognized Database Format When Filling DataAdapter

- 1 answer

I am trying to use listboxes to categorize data and I am trying to use SQL to do so.

form picture

that link is what the form looks like know and what i'm trying to do - to use the listboxes to view the records by student year.

For the first list box here is the code for the first listbox to sort the data by year:

Imports System.Data.OleDb

Public Class viewStudent

Private Sub viewStudent_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'ProjDataSet1.Details' table. You can move, or remove it, as needed.
    ' OleDbDataAdapter1.Fill(DataSet11)
End Sub

Private Sub lstYear_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstYear.SelectedIndexChanged
    Dim Year, SQLString As String
    Dim dtDetails As New DataTable()
    Dim dbDataAdapter As OleDbDataAdapter
    Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source = proj.accdb"
    Year = lstYear.Text
    SQLString = "SELECT * FROM Details WHERE Year = " & "'" _
        & Year & "'" & ""
    dbDataAdapter = New OleDbDataAdapter(SQLString, ConnectString)
    grdRecords.DataSource = dtDetails
End Sub
End Class

But i get the error in the link below:


Can someone help to fix this? Thank you!



The "Microsoft.Jet.OLEDB.4.0" provider is the older 32-bit provider that can only work with .mdb database files. To work with an .accdb database you need to use the newer "Microsoft.ACE.OLEDB.12.0" provider.

Since you have the 64-bit version of Access 2013 installed you already have the 64-bit version of the ACE provider. All you need to do is

  1. Modify the properties of your .NET project to run as a 64-bit application (ref: here), and

  2. Change the connection string in your code to use Provider=Microsoft.ACE.OLEDB.12.0.