c#用odbc调用mysql
conn.Open();
OdbcCommand oc = new OdbcCommand("", conn);
oc.CommandText = "insert into hbb_user(email,account,password,creat_time) values(?,?,?,?)";
oc.Parameters.Add("@creat_time", OdbcType.DateTime).Value =DateTime.Now;
像上面这句参数化语句
由于 OdbcType.DateTime格式是yyyymmddhhmmss,是精确到毫秒级的,
而mysql的datetime是到秒级别的,这样存储时候老报错
{"ERROR [HY000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.25]
Incorrect datetime value: '2014-03-04 19:46:22.511000000' for column 'creat_time' at row 1"}
System.Exception {System.Data.Odbc.OdbcException}
请问如何解决?
------解决方案--------------------oc.Parameters.Add("@creat_time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")).
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/