ASP.net访问mysql数据库时发生Unable to convert MySQL date/time value to System.DateTime错误

来源:互联网 发布:java 去除全角符号 编辑:程序博客网 时间:2024/05/18 15:56

 出现异常Unable to convert MySQL date/time value to System.DateTime的原因是因为mysql的Datatime字段中有格式为 '0000-00-00 00:00:00'的时间内容。

只需要在web.config中对数据库连接字符串增加红色部分内容即可:

  <add name="dbname" connectionString="server=127.0.0.1;User Id=root;password=123456;Persist Security Info=True;database=testDB;charset=utf8;allow zero datetime=true"   providerName="MySql.Data.MySqlClient" />