R L

R L

  • NA
  • 3
  • 1.5k

C# to Access Delete SQL Statement Error

Dec 15 2013 10:10 PM
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();


        }




Answers (3)