Lucky_dog

Unable to convert MySQL date/time value to System.DateTime问题解决方案

电脑版发表于:2020/5/26 14:51

出现“Unable to convert MySQL date/time value to System.DateTime”的错误,我猜想是数据类型有问题,后来发现是因为表中字段(date/datetime)的值默认缺省值为:0000-00-00/0000-00-00 00:00:00,这样的数据读出来转换成System.DateTime时就会有问题;

解决办法:
1、将该字段的缺省值设置为null,而不是0000-00-00/0000-00-00 00:00:00的情况;
2、在链接MySQL的字符串中添加:Convert Zero Datetime=True 和 Allow Zero Datetime=True两个属性;
3、将该字段设置成字符串类型;

关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢