Hello, I was trying to view all the data from a single from a database after the button "search" is clicked and the output will be inserted into corresponding textboxes for future editing. After I entered the ID(1) I get an "OleDbException was unhandled" " Data type mismatch in criteria expression." error. I can't figure out the problem at all. All the type for my database is text except for total_payment which is in currency.
Any help is greatly appreciated.
Dim connStr As String = "provider=Microsoft.ACE.OLEDB.12.0;Data Source=cars.accdb" Dim conn As New OleDbConnection(connStr) Dim command As OleDbCommand Dim dt As DataTable Dim da As OleDbDataAdapter Dim sqlStr As String Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim searchStr As String = CStr(txtSearch.Text) sqlStr = "select * from car where Renter_ID = '" & searchStr & "'" dt = New DataTable() da = New OleDbDataAdapter(sqlStr, connStr) da.Fill(dt) <<< This is where I got the error da.Dispose() If dt.Rows.Count = 0 Then MessageBox.Show("Not Found") Else txtID.Text = dt.Rows(0)("Renter_ID") txtName.Text = dt.Rows(0)("Renter_Name") txtIC.Text = dt.Rows(0)("Renter_IC") txtPhoneNumber.Text = dt.Rows(0)("Renter_Phone") txtCarType.Text = dt.Rows(0)("Rented_Car") txtTotal.Text = dt.Rows(0)("Total_Payment") End If txtSearch.Clear() End Sub
Edited 2 Years Ago by Pickletronic: Added more informations