Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

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" />

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?

like image 384
nielsv Avatar asked Jun 08 '13 18:06

nielsv


1 Answers

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.

Check this also: http://mdid.org/mdidwiki/index.php?title=Unable_to_convert_MySQL_date/time_value_to_System.DateTime_exception

To fix this problem, either replace all invalid timestamps with NULL or a valid timestamp, or add Allow Zero Datetime=true

like image 83
Soner Gönül Avatar answered Nov 13 '22 15:11

Soner Gönül