Bug #10782 MySqlDataAdapter crashes with a date field set to 0000-00-00
Submitted: 20 May 2005 23:03 Modified: 22 May 2005 9:30
Reporter: James Templet Email Updates:
Status: Can't repeat Impact on me:
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.4 OS:Windows (Windows XP SP2)
Assigned to: CPU Architecture:Any

[20 May 2005 23:03] James Templet
MySQL Connector/Net v1.0.4
MySQL Server 4.0.24 (using InnoDB)
Windows XP Service Pack 2
Microsoft Visual Studio 2003 (.NET version 1.1 with all service packs applied)

If you attempt to fill an empty data table from a MySqlDataAdapter, and one of the records contains a date field with 0000-00-00, the following exception will be thrown:

"An unhandled exception type 'MySqlData.Types.MySqlConversionException' occurred in system.data.dll

Additional information: Unable to convert MySQL date/time value to System.DateTime"

If I edit the database and correct the date in the date field, the application will no longer throw the exception and retrieve the data without any hangups.

Any query that is executed and returns records with a date of 0000-00-00 will crash the application.

How to repeat:
Make a record in a table that has a date field and make the date 0000-00-00. Then attempt to use a MySqlDataAdapter to fill a data table with the query selecting the record that has 0000-00-00 in the date field.

Suggested fix:
Instead of throwing an exception, return a default value that will catch the attention of the user and show that there is an invalid date set in the database.
[22 May 2005 9:28] Vasily Kishkin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at

Additional info:

The bug was already fixed in sources.
[22 May 2005 9:30] Vasily Kishkin
I tested on my test case and could't repeat the bug. My test case is attached.
[22 May 2005 9:30] Vasily Kishkin
Test case

Attachment: 10782.zip (application/x-zip-compressed, text), 3.64 KiB.

[17 Nov 2005 22:26] Geoff Blosser
I have this bug using .NET Connector ver.1.0.6.  I have two server hosts using identical binaries, 4.1.12a-nt-max.  One host exhibits this bug and the other doesn't.  The behavior I see is that the database returns a 0000-00-00 value even when there is valid data in the field.