nerdeasy
asked on
Insert NULL DateTime Linq to SQL
Hello,
I have a series of columns that request different dates however the end user will not know these dates when they first create the row.
I have about 15 fields that are DateTime
I have it setup with Linq to SQL so when I go to insert the field into Linq to SQL I get an error that the field cannot be NULL however I have it checked that the field can be nullable....
How do I setup Linq to SQL to allow me to insert a NULL into the Database? The database is setup to allow NULL.
Thanks
I have a series of columns that request different dates however the end user will not know these dates when they first create the row.
I have about 15 fields that are DateTime
I have it setup with Linq to SQL so when I go to insert the field into Linq to SQL I get an error that the field cannot be NULL however I have it checked that the field can be nullable....
How do I setup Linq to SQL to allow me to insert a NULL into the Database? The database is setup to allow NULL.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, this is how I was able to fix it...
I opened up the Designer Class for the Data Classes I changed System.Nullable<DateTime> to DateTime? and it worked exactly how I wanted it to.
:)
I opened up the Designer Class for the Data Classes I changed System.Nullable<DateTime> to DateTime? and it worked exactly how I wanted it to.
:)
ASKER
I've requested that this question be closed as follows:
Accepted answer: 0 points for nerdeasy's comment #a38292283
for the following reason:
I was able to fix it on my own
Accepted answer: 0 points for nerdeasy's comment #a38292283
for the following reason:
I was able to fix it on my own
nerdeasy
The resolution listed for this issue was exactly the one I suggested. Any reason for not awarding points?
Michael
The resolution listed for this issue was exactly the one I suggested. Any reason for not awarding points?
Michael
ASKER
Michael yes should have points sorry I didn't see your response.
cheers
Michael
Michael
http://stackoverflow.com/questions/5685355/how-to-set-sql-datetime-to-null-from-linq
or you can simply assign
SqlDateTime.Null