Advertisement

05.13.2008 at 08:21PM PDT, ID: 23400188
[x]
Attachment Details

SqlDateTime overflow.  Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM

Asked by kwh3856 in Microsoft Visual C#.Net

Tags: Microsoft, Visual Studio 2005, C#, Date Time Fields

When I attempt to write a record to the database I get this error message.  I understand the error message occurs because I have left one of the date fields blank but in many cases the data is not necessary.  What is the easist way to program around this so this error does not occur if the field is left blank?

Here is some sample code where I get one of the data fields:

cmd.Parameters.Add("@DATEOFEXAM", SqlDbType.DateTime).Value = dtDateOfExam.Value;

cmd.ExecuteNonQuery();  --- error occurs here when the record is written to the tableStart Free Trial
[+][-]05.13.2008 at 08:40PM PDT, ID: 21561084

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 08:56PM PDT, ID: 21561147

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 09:21PM PDT, ID: 21561232

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 09:41PM PDT, ID: 21561315

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C#.Net
Tags: Microsoft, Visual Studio 2005, C#, Date Time Fields
Sign Up Now!
Solution Provided By: pratima_mcs
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628