I am trying to convert the data from a calender control from Ajax toolkit (for Date of Birth) using the code
create.DOB = System.DateTime.Parse(txtDOB.Text); but it throws an exception saying conversion to smalldatetime failed.
I also tried
create.DOB = System.DateTime.Parse(txtDOB_CalendarExtender.ToString()); .. still the exception is the same.
here create is the object of the class where I have defined the properties for passing the data into stored procedures for inserting the data. The Database works on smalldatetime everywhere.
the DOB property defined in the main class is of type DateTime..
Dev1411
Member
7 Points
184 Posts
Conversion to DateTime
May 23, 2012 03:46 PM|LINK
hi all,
I am trying to convert the data from a calender control from Ajax toolkit (for Date of Birth) using the code
create.DOB = System.DateTime.Parse(txtDOB.Text); but it throws an exception saying conversion to smalldatetime failed.
I also tried
create.DOB = System.DateTime.Parse(txtDOB_CalendarExtender.ToString()); .. still the exception is the same.
here create is the object of the class where I have defined the properties for passing the data into stored procedures for inserting the data. The Database works on smalldatetime everywhere.
the DOB property defined in the main class is of type DateTime..
Where am I wrong ? Kindly help urgently
Thanks in advance