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
Loading
ToBePosted Feb 27, 2013, 9:42 AM
any reply plz for the this issue :(
ToBePosted Feb 27, 2013, 6:43 AM
I tried your code and the error is not coming but it's adding Null value in the database for Reg_Date .
venkata kumarPosted Feb 27, 2013, 6:31 AM
while sending back you need to convert "dd/MM/yyyy" to MM/dd/yyyy"
try this the fallowing
txtdate.Text= DateTime.Now.Date.ToString();
string dt = (txtdate.Text);
string[] s = dt.ToString().Split('/');
string strDob = s[1] + "/" + s[0] + "/" + s[2];
dt=strdob;
cmd.Parameters.AddWithValue("@Reg_Date", dt);
ToBePosted Feb 27, 2013, 5:12 AM
I tried it but I'm still getting the same error :(
venkata kumarPosted Feb 27, 2013, 4:26 AM
try this
txtdate.Text= DateTime.Now.Date.ToString();
string dt = (txtdate.Text);
otherwise what is format of datetime is "dd//MM/yyyy" or mm/dd/yyyy"