0

can someone help me what is wrong with my code? It always says "Syntax error in INSERT INTO statement. "

try
        {

            OleDbConnection Con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\MotoFix.mdb;");



            Con.Open();
            OleDbCommand Com = new OleDbCommand();

            Com.Connection = Con;
             Com.CommandText = "INSERT INTO Order VALUES ('" + txtRandomOrder.Text + "','" + txtCode.Text + "')";
              Com.ExecuteNonQuery();
             Con.Close();
        }
        catch (Exception ex)
        {
            XtraMessageBox.Show(ex.Message);
        }

1 Answer 1

2

Order is a keyword in msaccess refer this link

http://office.microsoft.com/en-us/access-help/access-2007-reserved-words-and-symbols-HA010030643.aspx

change your statement to

"INSERT INTO [Order] VALUES ('" + txtRandomOrder.Text + "','" + txtCode.Text + "')";

and see if it works

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.