5
Reply

error converting datatype

ToBe

ToBe

Feb 27 2013 3:48 AM
2.9k
 Good morning

 I have this 2 lines to get the date time 

 
txtdate.Text= DateTime.Now.Date.ToString();
 string  dt = Convert.ToDateTime(txtdate.Text).ToString();


and i pass it  to the stored procedure as parameter as  following :

cmd.Parameters.AddWithValue("@Reg_Date", dt); 

when it reach the 
cmd.ExecuteNonQuery();

it will stop and give the error :
Error converting data type nvarchar to datetime
thanks in advance 




Answers (5)