Data type mismatch in criteria expression | Access, OleDb, C#

前端 未结 6 623
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 07:44

I read/update data from MS Access using C#. My code is:

public static void UpdateLastLogin(int userid, DateTime logintime) ///logintime = DateTime.Now
{
             


        
6条回答
  •  执念已碎
    2020-12-06 08:30

    Should it not be

    "UPDATE Customers SET LastLogin='@LastLogin'"
    

    And @LastLogin should be

    logintime.ToString("yyyy-MM-dd hh:mm:ss")
    

    edit Could you not just inline the whole thing?

    "UPDATE Customers SET LastLogin='" + logintime.ToString("yyyy-MM-dd hh:mm:ss") + "'"
    

提交回复
热议问题