Unrecognized Database Format When Filling DataAdapter
I am trying to use listboxes to categorize data and I am trying to use SQL to do so.
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.
Me.DetailsTableAdapter1.Fill(Me.ProjDataSet1.Details)
' 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)
dbDataAdapter.Fill(dtDetails)
grdRecords.DataSource = dtDetails
End Sub
End Class
But i get the error in the link below:
Can someone help to fix this? Thank you!
Answer
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
Modify the properties of your .NET project to run as a 64-bit application (ref: here), and
Change the connection string in your code to use
Provider=Microsoft.ACE.OLEDB.12.0
.
Related Questions
- → I can't do a foreign key, constraint error
- → How to implement DbDongle::convertTimestamps as workaround of invalid timestamps with MySql strict
- → MySQL error "Foreign key constraint is incorrectly formed"
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Laravel 5.1 QueryException when trying to delete a project
- → Using Array in '->where()' for Laravel Query Building
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel Eloquent Joining Strange query
- → convert time using mysql laravel 5
- → How to update a column after an expiration date in MySQL?
- → Foreign key constraint fails on existing key