I am reading / updating data from MS Access using C #. My code is:
public static void UpdateLastLogin(int userid, DateTime logintime)
{
string sql = @"UPDATE [Customers] SET [LastLogin]=?";
OleDbParameter[] prms = new OleDbParameter[] {
new OleDbParameter("@LastLogin",logintime)
};
using (DAL dal = new DAL())
{
dal.UpdateRow(sql, false, prms);
}
}
When it comes to dates, I have problems. This causes a โdata type mismatch in the criteria expressionโ. mistake. (I removed the WHERE clause for simplicity) Can I attach [LastLogin] =? single quotation mark, # characters .. doesn't help. Any guidance on how to handle DateTime objects with Access and OleDb would be greatly appreciated.
Thanks in advance.
source
share