Kevin, I did include warnings and notices along the way that the behavior is
changing and will likely introduce a new connection string option to allow
for converting illegal datetimes to DateTime.MinValue.
The old ByteFX provider simple converted every illegal date that it saw to
DateTime.MinValue. This certainly avoided any casting problems but then
reader.GetValue(x).ToString() on a column that has the value '0000-00-00'
would not return '0000-00-00' and many people saw this as a problem. So
what do you do?
Regarding null datetime fields, those should work without trouble. However
you need to keep in mind that when illegal or nullable datetimes are in the
mix, you cannot simply always convert to DateTime with something like
strDate = Ctype( dr("myDate"), Date). You need to check that a column is
not null first.
My suggestion is that you make your date column allow nulls but never allow
illegal values such as 0000-00-00. Then in your code you can do something
If reader.IsDBNull(x) then
... Handle my null case
strDate = Ctype( dr("myDate"), Date)
> -----Original Message-----
> From: James Moore [mailto:banshee@stripped]
> Sent: Sunday, February 13, 2005 12:29 PM
> To: 'Kevin Turner'; dotnet@stripped
> Subject: RE: Date casting problem
> You probably want to take a look at the mailing list archives
> for the discussions on this one over the last couple months.
> The short answer is that it's difficult to define what the
> correct behavior is; MySQL and .Net have different ideas of
> what legitimate dates are and it's not clear that there's a
> perfect way to reconcile them.
> - James
> MySQL on .NET Mailing List
> For list archives: http://lists.mysql.com/dotnet
> To unsubscribe: