Geeks With Blogs

@azamsharp
  • azamsharp Anyone done Blackberry development using Blackberry JDE tool? about 1 day ago
  • azamsharp One person gave a bad review of my app and now the rank fell to the bottom! :( Sad about 1 day ago
  • azamsharp Coming back to Windows after using Mac exclusively for 6-8 months. Windows feel slow, crappy. Every freaking thing takes time! WTF about 2 days ago
  • azamsharp Everyone! If you have bought Vegetable Tree app then I would appreciate if you can rate and review the app on the app store. about 2 days ago
  • azamsharp Idea: An iOS hangout on Google hangouts. devs join hangout first come first service basis. Talk about iOS, apps stuff. Everything recorded! about 2 days ago

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};
            FingerPrintRepository.Save(finger);  

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:

SetDefaultDLINQ

 

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: GeeksWithBlogs.net | Join free