Solved

LINQ DateTime save is not working when field need to be null

Posted on 2011-09-07
2
258 Views
Last Modified: 2012-05-12
I am currently trying to save a record to a sql server express database.  One of the fields is a DateTime field that needs to be null upon record creation.  For some reason, even though the linq object that represents the data has a null value set for the record, I keep getting a SqlDateTime error indicating that the date enter should be between 1753 and ......., forgot the max range.  Anyway, if I am setting this field as null why is this occuring and what can I do to fix it(workarounds)?
0
Comment
Question by:rawcoder
2 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 36495552
For the field to accept null values it should be defined as DateTime? not DateTime.
0
 
LVL 4

Accepted Solution

by:
guramrit earned 500 total points
ID: 36496819
There're two reasons for this error to occur.
1. In database, you didn't set the column with datetime datatype to Allow Null
2. In code, you'd forgot to set a value to some other column with datetime datatype.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS2013 publish C# application Created folder -- where is it??? 10 28
Add or delete table rows 10 54
FInd Image Control Gridview 3 21
Groupbox Control ? 2 18
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question