AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
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
Speech Technology Magazine
Windows 8: 50 Questions and Answers You Need to Make a Decision (Normally $9.95)
Integrating Silverlight 4 with SharePoint 2010 - Free 42 Page Sample Chapter