当使用.NET connector 连接MYSQL数据库,检索某些数据的时候,你可能会得到一个错误信息:
"Unable to convert MySQL date/time value to System.DateTime"
这是因为在日期列中有"0000-00-00"数据值,要修正这个问题,你可以把这些数据设为null,或者在连接字符串中设置"Allow Zero Datetime=True"
例:
<add name="MySqlCon" connectionString="Database=test;Data Source=localhost;User Id=root;Password=123456;pooling=false;CharSet=utf8;Port=3306;allow zero datetime=true"/>
本文详细介绍了在使用.NETconnector连接MYSQL数据库时遇到无法转换MySQL日期到System.DateTime的问题,提供了将日期列中0000-00-00数据设为null或在连接字符串中设置AllowZeroDatetime=True的解决方案。
209

被折叠的 条评论
为什么被折叠?



