我在访问数据库时出现问题,然后在INSERT INTO语句中出现错误语法错误。我的代码是:
string str = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/Geeta/Desktop/Database2.accdb;Persist Security Info=False;");
OleDbConnection conn = new OleDbConnection(str);
conn.Open();
string query = "insert into data (FirstName,Email,Password,Address) values ('" +
txt_fstname.Text + "','" + txt_email.Text + "', '" +
txt_pass.Text + "', '" + txt_add.Text + "')";
OleDbCommand cmd = new OleDbCommand(query,conn);
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("Default.aspx");
plz建议我。
“谢谢”
答案 0 :(得分:3)
密码是Jet / ACE SQL中的reserved word,因此您必须将其括在方括号中:
string query = "insert into data (FirstName,Email,[Password],Address) values ('" +