insert into book_issues(stu_id,stu_name,book_id,book_title,
user_type,issu_date,exect_return_date,is_return)
values
( 5,'thenmozhi',10,'windows programming',
'Student','10-10-2015 16:23:55','15-10-2015 16:23:55','False');
我收到此代码的错误,请告诉我我的错...
答案 0 :(得分:0)
你不应该这样做。 总是尝试参数化的方式。
喜欢:cmd.Parameters.AddWithValue("@datecreation", Convert.ToDateTime(datecreation));
你可以这样做:
using(SqlConnection conn = new SqlConnection("Connectionstring"))
using (SqlCommand cmd = new SqlCommand())
{
string sql = "insert into Usertable ";
sql += "values(@mVendid, @usrname, @usrpass, @datecreation, @createdby)";
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("@mVendid", mVendid);
cmd.Parameters.AddWithValue("@usrname", username);
cmd.Parameters.AddWithValue("@usrpass", userpass);
cmd.Parameters.AddWithValue("@datecreation", Convert.ToDateTime(datecreation));
cmd.Parameters.AddWithValue("@createdby", createdby);
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
}
只需根据您的代码更改此内容。