I am getting below Error, When I put Multiple Conditions with WHERE Clause. Error:- Data type mismatch in criteria expression.
My Query:-
this.query = "UPDATE [Attendance] SET [TimeOut]='" + DateTime.Now.ToShortTimeString() + "' WHERE [Emp_Id]='" + txtEmpId.Text + "'and[Date]='" + this.Date + "'";
Access SQL tends to be rather flexible when accepting Date/Time values as strings. However, since you really should be using a parameterized query anyway because
dd-mm-yyyy
format, consider using the following approach
this.query = "UPDATE [Attendance] SET [TimeOut]=? WHERE [Emp_Id]=? AND [Date]=?";
cmd.CommandText = this.query;
cmd.Parameters.AddWithValue("?", DateTime.Now.ToString("H:mm:ss"));
cmd.Parameters.AddWithValue("?", txtEmpId.Text);
cmd.Parameters.AddWithValue("?", this.Date);
cmd.ExecuteNonQuery();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.