Click here to Skip to main content
15,920,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am entering datetime in runtime in text format, but when it is getting inserted in sql server database, showing error
that cant convert char datatype to datetime format.

i have used format(datetimepicker.value)

but still showing error.

Can anyone help?

i will be obliged
thanks in advance.
sudeshna
Posted
Updated 8-Jul-13 18:58pm
v2

1 solution

You can do it in two ways....

one from code behind and second from sql server

1)
VB
DateTime Dob = Convert.ToDateTime(TextBox2.Text);


2)
SQL
SELECT convert(datetime,'2004-08-24',120)
 
Share this answer
 
Comments
sudeshna from bangkok 8-Jul-13 3:03am    
Thanks a lot. problem solved
Nirav Prabtani 8-Jul-13 3:04am    
please up vote this solution if you satisfied with it...:)
sudeshna from bangkok 9-Jul-13 0:27am    
sir, i had written the code convert.todatetime(datetimepicker.value) but still again showing same error. cant convert char to datetime datatype format

can you help me again plz

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900