Solved

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

Posted on 2011-09-07
2
259 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

756 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