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

0


source to share


2 answers


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.

+1


source


Fix - It turned out that the problem was with the connection string to connect to mySQL database.



Also I didn't know that it is possible to delete a table in DBML using Server Explorer. All I had to do was connect to the database and then drop the table to DBML.

0


source







All Articles