9

I have a simple table with few date fields.

Whenever I run following query:

var docs = ( from d in base.EntityDataContext.document_reviews
select d ).ToList();

I get following exception:

Unable to convert MySQL date/time value to System.DateTime. 
MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime

The document reviews table has two date/time fields. One of them is nullable.

I have tried placing following in connection string:

Allow Zero Datetime=true;

But I am still getting exception.

Anyone with a solution?

0

2 Answers 2

12

@effkay - if you solved this it would be great if you could post the answer.

Also if anyone else has a solution that would be great too :).

Edit:

The solution can be found in the http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html connector documentation.

I needed to set "Convert Zero Datetime" to true, and now it works.

hth.

Sign up to request clarification or add additional context in comments.

4 Comments

It was a bug in mysql provider for .net :(
Nice tip the Convert Zero Datetime, but i have the problem that i cant insert from EF to mysql table the value '0000-00-00', and i need to.. is there a posibility to insert a value of datetime like that from EF?
yes setting: Convert Zero Datetime=True in provider connection string part solved this for me
5

You need to set Convert Zero Datetime=True in connection string of running application

1 Comment

Works, thanks. Much easier than the coding solution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.