ToBe

ToBe

  • NA
  • 164
  • 94.7k

error converting datatype

Feb 27 2013 3:48 AM
 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)