Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Posted by YeYanAung on  6/13/2007 12:39:40 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
In my project, i used two cultures. One thai(th-TH) and another english(en-US). I populate some date range from my database to a dropdownlist. The format is 'MMM dd, yyyy'. So when i tried to insert the date into my database with english culture it works fine. When i change the culture to thai version, the date changes to Thai format, but when i tried to insert into database it gives the following error.

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

When i debug, the year value is 1464. What is the problem and do anyone suggest a solution for this?

Post Your Reply Post New Question

 Viewer's Reply
set the culture info
Answered By Moderator1 on 7/5/2007 8:16:22 AM
You have to set the culture info before inserting into database. follow the code below

CultureInfo ci = Thread.CurrentThread.CurrentCulture;
DateTime yourdatetime = Convert.ToDateTime(DropDownList1.SelectedValue, ci);

Then insert 'mydatetime' yourdatetime value to the database table.
Post Your Reply If you still have problem, post it again under this reply for better response.

Sponsored by
The Beginner's Guide to Joomla
Simply JavaScript - Free 150 Page Preview!
When Good HTML Goes Bad: How You Can Protect Your Web Applications