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

前端 未结 6 625
佛祖请我去吃肉
佛祖请我去吃肉 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:18

    Try setting the "DBTYPE" property of the parameter to identify it as a date, datetime or datetime2 as appropriate...

    prms[0].DbType = DbType.DateTime;
    

    There are 7 signatures to the new OleDbParameter() call, so you may change the signature instance, or just do explicitly as I sampled above since you only had 1 parameter in this case.

提交回复
热议问题