3
Answers

Syntax Error in INSERT INTO Statement (Insert Records)

Akemi Chou

Akemi Chou

10y
729
1
I always have experienced this "INSERT INTO Statement" Syntax Error, can someone help me how to solve this?

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);
            }

Answers (3)