标准表达式不匹配的问题是由于在调用时将OleDbType分配给了用于表示DateTime.Now值的参数
AddWithValue。
AddWithValue选择的OleDbType是
DBTimeStamp,但是Access想要一个
OleDbType.Date。
http://support.microsoft.com/kb/320435
在NET上搜索时,我发现了另一个有趣的提示。核心问题在于OleDbParameter无法处理DateTime.Now的毫秒部分。可能将OleDbType强制为Date毫秒部分被省略。我还发现,如果我们从日期中删除毫秒,则插入也可以与DBTimeStamp类型一起使用。
cmd.Parameters.AddWithValue("?", GetDateWithoutMilliseconds(DateTime.Now));private DateTime GetDateWithoutMilliseconds(DateTime d){ return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);}哦,好,等待有人对此进行更好的解释。



