Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now