无法MySQL的日期/时间值转换为System.DateTime在VS2010 [英] Unable to convert MySQL date/time value to System.DateTime in VS2010

查看:4028
本文介绍了无法MySQL的日期/时间值转换为System.DateTime在VS2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想从我的MySQL数据库中加载数据,我总是得到这个错误:

when I want to load data from my mysql database I always get this error:

无法MySQL的日期/时间值转换为System.DateTime

Unable to convert MySQL date/time value to System.DateTime

这是我的ConnectionString:

This is my connectionstring:

<add name="gdmwebsiteEntities" 
     connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;database=gdmwebsite&quot;" 
     providerName="System.Data.EntityClient" />

我已经添加了零转换日期时间=真正的加我的ConnectionString但没有改变的结束。结果

I've already added "Convert Zero Datetime=True" add the end of my connectionstring but nothing changed.

    <add name="gdmwebsiteEntities" 
     connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;User Id=root;database=gdmwebsite&quot;
     Convert Zero Datetime=True
      Allow Zero Datetime=True"
     providerName="System.Data.EntityClient" />

有另一种方法解决这个?

Is there another method for fixing this?

推荐答案

设置您的连接字符串中这些配置。

Set both of these configurations in your connection string.

"Convert Zero Datetime=True"
"Allow Zero Datetime=True"

http://bugs.mysql.com/bug.php?id=26054

请检查下连接选项手动,并设置允许零
  日期时间为真,作为附加的图片,而错误会
  了。

Please check manual under connect options and set "Allow Zero Datetime" to true, as on attached pictures, and the error will go away.

检查,这也:<一href=\"http://mdid.org/mdidwiki/index.php?title=Unable_to_convert_MySQL_date/time_value_to_System.DateTime_exception\">http://mdid.org/mdidwiki/index.php?title=Unable_to_convert_MySQL_date/time_value_to_System.DateTime_exception

要解决此问题,是替换所有无效的时间戳与NULL
  或有效时间戳,或添加允许零日期时间=真正

这篇关于无法MySQL的日期/时间值转换为System.DateTime在VS2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆