Hi firends,
I wanna send a DataTime value to DateTime field of DB
but my program has an error : Conversion failed when converting datetime from character string
Thanks....
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Subhendu DePosted Dec 10, 2010, 2:23 AM
You have DateTime field in DB. Now if you are using stored procedure then make the parameter as dbtype.datetime/dbtype.date and if you are using sql query try to use parameterized query and make the as dbtype.datetime/dbtype.date
When you are passing datetime from c# code, use Convert.ToDateTime(
Try it and let me know, if it solves your problem or not.
Thanks.....
Suthish NairPosted Dec 11, 2010, 2:38 PM
http://www.csharp-examples.net/string-format-datetime/
http://en.csharp-online.net/CSharp_Format_Specifiers%E2%80%94DateTime_Format_Specifiers
shimaPosted Dec 10, 2010, 5:13 PM
I need a pattern such as mm/dd/yyyy , but i dont know how use this one?!
Santhosh NPosted Dec 10, 2010, 10:39 AM
yourdatevalue.ToString(mm/dd/yyyy ");
Suthish NairPosted Dec 10, 2010, 9:43 AM
Or post your code
Subhendu DePosted Dec 10, 2010, 7:41 AM
Sample data what u want to add to table.
Thanks.....
shimaPosted Dec 10, 2010, 7:30 AM
I convert my date to DateTime , but i have this error yet!
Conversion failed when converting datetime from character string
dear santosh ,
whats your mean from this? "Use this convert your datatime field to convert to desired format
ToString(mm/dd/yyyy "); "
Santhosh NPosted Dec 10, 2010, 2:24 AM
Use this convert your datatime field to convert to desired format
ToString(mm/dd/yyyy ");