Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi,

i want to save date field to database . i am creating a date here like the code i given below . i am getting the error
String was not recognized as a valid DateTime.

here is the code i am using
string res= (DateTime.Now.Date.ToString("dd/MM/yyyy") + " " +          txtTimeIn.Text.ToString() + ":00 " + ddlTimeInAMPM.SelectedValue.ToString());
DateTime aaaaaa = (DateTime) (res)
txtTimeIn.Text= 9:00
ddlTimeInAMPM.SelectedValue=AM

i know the case of casting string to datetime but . it works last time suddenly it doesnt
Posted
Updated 25-May-11 21:20pm
v2

Make it this way (DateTime.Now.ToString("dd/MM/yyyy")
 
Share this answer
 
hi, thank you for your replay i solve my problem

DateTime.Now.Date.ToString("MM/dd/yyyy")


thank you all
 
Share this answer
 

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