removebutton_Click
protected void removebutton_Click(object sender, EventArgs e)
{
string RemoveSQL;
OleDbConnection mDB = new OleDbConnection();
mDB.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;Data source="
+ Server.MapPath("~/App_Data/database.accdb");
mDB.Open(); OleDbCommand cmd;
Button removebutton = (Button)sender;
Label carttransactionlabel = (Label)removebutton.Parent.FindControl("carttransactionlabel");
int intTransNo = int.Parse(carttransactionlabel.Text);
RemoveSQL = "DELETE FROM orderItems"
+ "WHERE iTransaction_No = @TransNo";
cmd = new OleDbCommand(RemoveSQL, mDB);
cmd.Parameters.Add("@TransNo", OleDbType.Integer).Value = intTransNo;
cmd.ExecuteNonQuery();
mDB.Close();
}
What I am trying to accomplish here is that when the user clicks on the removebutton button, the SQL command RemoveSQL will remove the entire row of transaction from the orderItems table in MS Access based on the transaction number (carttransactionlabel).
Table enter image description here
However, when I try to click on the removebutton button, this error appears enter image description here
Apparently there's a syntax error in the SQL statement which I can't seem to spot. Help would be appreciated.