0 pts.
 hi i need help
in c#.net we are taking datetime from datetimepicker we are storing datetime into sqlserverdatabase.
in sqlserver we are taking datetime datatype.

we write code like this:
Datetime dt=DateTimePicker1.value;
cmd=new sqlcommand("insert into values(date) tablename('"+dt+"')",con);
cmd.excutenonqury();

we are seleted date datetimepicker as 19/12/2006
after excuting this one we are getting error like this:
conversion of char data type to datetime data type resulted in an out of range datetime value
ASKED: Dec 19, 2006  4:33 AM GMT
UPDATED: December 19, 2006  10:54:23 AM GMT
0 pts.

Answer Wiki:
MSSQL does not recognize day/month/year as a valid date format. It can be reversed to year/month/day or use month/day/year.
Last Wiki Answer Submitted:  Dec 19, 2006  8:53 AM (GMT)  by  MooseDrool   0 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




 

you are using European style dates, DD/MM/YYYY and SQL Servert is expecting American style dates MM/DD/YYYY. change the code that looks like (’”+dt+”‘) to look like (’”+Format(dt,”MM/DD/YYYY”)+”‘) should do the trick.

 0 pts.