Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

While working on an application I faced the following error when trying to submit changes to the database using DLINQ:

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

So, from the exception it seems like my date is initialized to a wrong state. By, the way I put the default value for my date to be GETDATE() in the database and while inserting I was not setting the date property namely "DateCreated" and "DateModified". So, in order for the submit changes to work I must set the "DateCreated" and "DateModified" properties as shown below:

FingerPrint finger = new FingerPrint() { InstanceID = template.InstanceID, FingerImage = digSignUI
             , DateCreated = DateTime.Now, DateModified = DateTime.Now};

But, I don't want to set the properties since it is default to "GETDATE()" in the database. Why should I do extra work?

So, in order for DLINQ to automatically insert your default values in the database you must change the "Auto Generated Value" to true. Open your "dbml" file in the designer and right click on the column you want to insert default data in my case it is "DateCreated" and set "Auto Generated Value = True". Here is the screen shot below:



One more thing that bugs me about DLINQ is that it does not automatically update the auto-generated code when I change the schema of the database table. So, I have to first delete the table from the designer and then add it back again. It would be good if we can just refresh the design view to get the latest schema.

Posted on Thursday, January 10, 2008 11:19 AM | Back to top

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

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: