My datatype in the Database Table is Short Text and I'm not sure Why I'm getting this error at command2.ExecuteNonQuery();
Error Message
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Data type mismatch in criteria expression.
My Codes
OleDbCommand cmd1 = new OleDbCommand();
cmd1.Connection = con;
cmd1.CommandText = "SELECT * FROM Customers Where FirstName=@FirstName OR LastName=@FirstName OR NRIC=@FirstName";
cmd1.Parameters.AddWithValue("@FirstName", txtSearch.Text);
OleDbDataReader read2 = cmd1.ExecuteReader();
string id = "";
while(read2.Read())
{
id = read2["id"].ToString();
}
OleDbCommand command2 = new OleDbCommand();
command2.CommandText = "UPDATE CheckIn_Details SET ModeOfCheckIn='True' WHERE ID='" + id + "'";
command2.Connection = con;
command2.ExecuteNonQuery();
If ID is AutoNumber then you do not need quotation marks. Try this instead:
command2.CommandText = "UPDATE CheckIn_Details SET ModeOfCheckIn='True'
WHERE ID=" + id;