MySQL and null date values

Oct 23
2012

Today I have lost about two hours to work around a very strange MySQL Connector.NET behaviour.

This code

oMySQLDataReader:IsDbNull( nFieldPos )

gives an exception if the value is a date and has a null value. The exact error was

“unable to convert MySQL date/time value to System.datetime”

I have tried several things, but even

oMySqlDataReader:GetMySQLDateTime( nFieldPos)

fails.
Some messages suggested to add

“Allow Zero Datetime=true;”

to the connection string, but with this one I was unable to retrieve ANY date value.

Only adding

“Convert Zero Datetime=true;”

to the connection string solved the problem.

Comments are closed.