Click to See Complete Forum and Search --> : Conversion failed when converting datetime from character string


Webnerd
05-28-2008, 09:14 AM
I can't get my SQL to execute properly:


Conversion failed when converting datetime from character string


The Database column is a DateTime type and here is where I add the parameter:


SqlParameter myParam13 = new SqlParameter("@sContactDate", SqlDbType.DateTime);
myParam13.Value = DateTime.Parse(Request.Form["bestContactDate"]);
myCommand.Parameters.Add(myParam13);


Anyone know how to fix?

Thanks

WizardOfOz
06-26-2008, 03:32 PM
Two suggestions:
1. Have you tired adding the ToString() to the Request line:
myParam13.Value = DateTime.Parse(Request.Form["bestContactDate"].ToString());

2. myParam13.Value = Convert.ToDateTime(Request.Form["bestContactDate"].ToString());