Date-Time Format in C# and SQL Server
-
hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all
-
hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all
Hi, could you post the code how you are trying to insert the new row? I guess the sql-server is expecting a datetime-row and you try to store the date as string. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
hi all, I use sql server 2005 and C#(asp.net) to build a library system (web site), but my problem is.. i can insert a row into database at datetime format MM/dd/yyyy, but if my server date format changed to any format my web site is stop work and do an exception ..( the conversion of a char data type to a datetime data type resulted in an out-of-range datetime value). can u help me please,,, thanks all
Try to Change the DateFormat to MM/dd/yyyy before inserting into database Like this
DateTime.Today.ToString("dd-MMM-yyyy")