0
private void btnSubmit_Click(object sender, EventArgs e)
{
OleDbCommand cmd;
string cmdstring = "INSERT INTO Names (Surname,FName) VALUES('" + txtSurname.Text + "','" + txtFName.Text + "')";
OleDbConnection myConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
cmd = new OleDbCommand(cmdstring, myConnection);
myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
}
我想補充Surname
和FName
訪問數據庫,但錯誤已經顯示出這樣的"syntax error"
。 我不知道爲什麼。INSERT INTO Access數據庫與C#
您收到的具體錯誤是什麼?你也應該看看SQL注入以防止對你的應用程序的攻擊。 – 2013-04-21 17:27:37
@DarrenDavies我同意 – mattytommo 2013-04-21 17:29:14
@mattytommo - 偉大的思想;) – 2013-04-21 17:30:15