LINQ SqlDateTime Overflow Error

Wednesday, 27 May 2009 05:46 by Jeff

Problem

Using the following tools Visual Web Developer Express 2008 and Sql Server Express 2008, when inserting a new row into my test User table I got the following error :

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

My table definition has 2 columns 

Name:DateAdded  Type : datetime Allow Nulls : No Default Value : getdate()
Name:DateTimeStamp  Type : datetime Allow Nulls : No

 

Solution

My LINQ insert statement set

DateTimeStamp = DateandTime.Now

and assumed that SQL Server Express 2008 would handle the DateAdded column for me.

Looking at the debug I could see DateTimeStamp was set correctly and DateAdded was empty, still on the assumption that SQL Server Express was taking care of things for me.

What fixed this issue for me was going back to my .dbml diagram, selecting the definition of DateAdded and setting the Auto Generated Value property to True.

 

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   LINQ | Visual Studio Express 2008
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed