I have the following DELET Button to delete data from an Access Database but the following SQL Statement is generating this error:
Syntax error (missing operator) in query expression '(Loan Number='5545')'.
Loan Number is a field in the Access DataBase. Thanks
private void button8_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Desktop\Sample.accdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("delete * from DataTable WHERE (Loan Number='" + int.Parse(textBox1.Text)+"')", con);
cmd.ExecuteNonQuery();
con.Close();
}
C# to Access Delete SQL Statement Error
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Abhay ShankerRank #375 · 6.7K reputationPosted Dec 15, 2013, 5:22 PM EST
("delete * from DataTable WHERE (Loan Number='" + int.Parse(textBox1.Text)+"')",
so try either way
1.Rename the column
2.replace Loan Number with [Loan Number]
3.confirm query is executing by running query in MS AccessBuilder
R L3 reputationPosted Dec 15, 2013, 5:34 PM EST
Shankar MRank #874 · 2.5K reputationPosted Dec 15, 2013, 6:08 PM EST