MySql Null DateTime and MS.net don't play well
Here's the question.
I have a table (mySQL) that contains dates and some of them are null. I know I can use DateTime? or Nullable to allow null, but I'm not sure where to set it.
What I have tried:
I have built a class in dblm. The date property has the following attributes:
Nullable : True
Server Data Type : DateTime
Type : NUllable<DateTime>
These settings allow my code to be generated. When I debug this you get this exception: System.NullReferenceException: Object reference not set to object instance.
If I try with these attributes:
Nullable : True
Server Data Type : NUllable<DateTime>
Type : NUllable<DateTime>
I am getting the same exception as above.
Other ways that didn't work:
Nullable : True
Server Data Type : DateTime?
Type : NUllable<DateTime>
Nullable : True
Server Data Type : DateTime?
Type : DateTime?
I am using .net 3.5 Framework
thank
source to share
I remember an issue with the ADO.NET mysql driver where it didn't play well with null date and time fields at all.
Even IsDBNull was throwing an exception on a null date / time field.
This could be a problem.
source to share