0

Hi Guys, <-- Newbie Here!

I seem to have an issue with an INSERT INTO statement when trying to add some textbox data into a DataSet and then update the backend table called 'cashOrders' in a Access Databse.

The Following code is being run from the 'Save Button'

       private void btnOrderSave_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

            cashOrdersTable.TableName = "cashOrders";

            DataRow DRO = cashOrdersDS.Tables["cashOrders"].NewRow();


            DRO["QTY"] = Int64.Parse(txtOrderQTY.Text);
            DRO["Description"] = txtBoxDescrip.Text.ToString();
            DRO["Supplier"] = txtBoxSupplier.Text.ToString();
            DRO["Date"] = dateTimePicker1.Text.ToString();
            DRO["Cost"] = decimal.Parse(txtBoxCost.Text);
            DRO["Sell"] = decimal.Parse(txtBoxSell.Text);
            DRO["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);


            cashOrdersDS.Tables["cashOrders"].Rows.Add(DRO);

            cashDA.Update(cashOrdersDS.Tables["cashOrders"]);

            MessageBox.Show("Added");
        }

Currently when Debugging and stepping through the Code it seems to get through until the final 'update' section. Where I get the following error message:

Syntax error in INSERT INTO statement.

Is anyone able to point me in the direction I am meant to look to resolve this issue?

If you need more code I could be happy to reply with is and help where I can.

Regards
Mark.

2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by sundog1
0

Did you assign a OleDbCommand to the OleDbDataAdapter's SelectCommand property? The command builder uses the SELECT query to construct other queries, such as the INSERT INTO query.

0

Hi nmailet, thanks for your reply.

Can you show me an example of what you mean?

0

Hi Guys.. I have sussed it out!

It was due to me using a KeyWord as one of the Columns in Access 2010. I changed all the headings I had with 'cash' on the beigning as a test and it worked fine.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.