Hi guys, Needing some help here please.

I have a 'Save button' setup on my form which seems to be working perfectly. It allows vales to be taken from text boxes and then presented on a datagrid view and also saved to the underlying databse.

The Code for this save button is below:

       private void btnSaveAcc_Click(object sender, EventArgs e)
        {

            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);


            DataRow DR = cashCustomersDS.Tables[0].NewRow();

            DR["CashAccRef"] = Int64.Parse(txtBoxAccRef.Text);
            DR["CashName"] = txtBoxName.Text.ToString();
            DR["CashAddress1"] = txtBoxAddr1.Text.ToString();
            DR["CashAddress2"] = txtBoxAddr2.Text.ToString();
            DR["CashTown"] = txtBoxTown.Text.ToString();
            DR["CashAddress3"] = txtBoxCounty.Text.ToString();
            DR["CashAddress5"] = txtBoxPostCode.Text.ToString();

            cashCustomersDS.Tables[0].Rows.Add(DR);

            cashDA.Update(cashCustomersDS, "cashCustomers");

            MessageBox.Show("Customer Added");
        }

Now... the issues seems to be with the 'Delete' Button. The When clicking on a row in the gridview the values are populated into the text boxes (incase of editing is needed) but when clicking Delete I receive an error on the 'cashDA.Update' line.

Value cannot be Null.
Parameter Name: dataTable.

The code for the 'Delete' button is as follows:

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

            if (dataGridView2.SelectedRows.Count > 0)
            {
                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);



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

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }

Now, as long as I take out the following line... ''cashDA.Update(cashOrdersDS.Tables["cashOrders"]);'' the code seems to run fine and removes a line from the gridview. So it seems like there is an issue with updating the underlying database.

Any help on this would be great as I've been scratching my head on this all Friday.

regards
Mark.

Recommended Answers

All 50 Replies

Once again... You do not open a connection to the database before the line calling the dataadapter.Update() and then closing it after the line calling it.

It cant find a data table if it cant connect to the database now can it :)

This method call requires manual opening and closing of the connection unlike datadapter.Fill()

Hi Mikey,

I have done as you said and moved the connection after the update line but the error is still the same?? :S

The code should look like this:

     private void btnOrderDelete_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            //connection declared here
            if (dataGridView2.SelectedRows.Count > 0)
            {
                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                //connection opened here
                cashDA.Update(cashOrdersDS.Tables["cashOrders"]);
                //connection closed here
                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }

That correct on your screen?

Hi Mikey.

This is the code i'm using and still get the same problem:

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

            if (dataGridView2.SelectedRows.Count > 0)
            {
                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();

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

                cashCustom.Close();

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }
    }
private void btnOrderDelete_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            if (dataGridView2.SelectedRows.Count > 0)
            {
                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();
                cashDA.UpdateCommand = cb.GetUpdateCommand();
                cashDA.Update(cashOrdersDS.Tables["cashOrders"]);
                cashCustom.Close();
                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }
    }

Try that.

Hi Mikey,

I've added the updatecommand as requested to try. It has brought back a differnt error this time referring to Dynamic SQL generation?

I have attached a screenshot to this reply for you to see.

Is it expecting some kind of Row ID?

Ummm going back to the original post. Can you check in the watch window whether the data set contains that table etc as we did in one of your other questions?

Just incase that ghost has come back to haunt us.

Hi Mikey,

OK, I've put a piece of code in place to show there is a table in the DS. result is in Screenshot.

Code used:

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

            if (dataGridView2.SelectedRows.Count > 0)
            {

                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();

                MessageBox.Show(cashCustomersDS.Tables[0].ToString());
                cashDA.UpdateCommand = cb.GetUpdateCommand();
                cashDA.Update(cashOrdersDS.Tables["cashOrders"]);

                cashCustom.Close();

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }
    }

but I still get the error. (in screensthot).

just to add some more info...

If i chance the coding to this...

"MessageBox.Show(cashCustomersDS.Tables[0].Rows.Count.ToString());"

It shows 8 rows within the dataset but only 7 rows on my grid but surely that doesn't matter because the extra row would be the ID on the table?

Yeah you need to remove the cashDA.UpdateCommand = cb.GetUpdateCommand(); line, that wont work for you.

What happens if you use the line cashDA.Update(cashOrdersDS.Tables[0]);?

Good morning Mikey,

If If Chage the code to have the amendment in you suggest it runs fine but does not keep update the table in the back end as once you click off the order and go back to it the line re-appears.

Code using:

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

            if (dataGridView2.SelectedRows.Count > 0)
            {

                cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();

                MessageBox.Show(cashCustomersDS.Tables[0].Rows[0].ToString());
                unbind();
                cashDA.Update(cashOrdersDS.Tables[0]);

                cashCustom.Close();

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }

Haaaaannngggg On.

Whats cashOrdersTable? A lone datatable? Changes to this wont affect the tables in the dataset and so therefore your changes wont be pushed back to the database.

Similarly to another of your questions we need to be removing the rows from the table referenced in the dataset and not the lone datatable :) try that.

Hi Mikey,

But surely cashOrderstable IS the table referenced in the Dataset.. See the Code below from a method further up the code...

Code:

           else if (radioBtnPrinted.Checked == true)
            {
                //Below selects data from the Current Selected Row, finds out the cell value an populates the current text box//
                txtBoxAccRef.Text = dataGridView1.SelectedCells[0].Value.ToString();
                txtBoxName.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtBoxAddr1.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtBoxAddr2.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtBoxTown.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtBoxCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtBoxPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();

                DataGridViewRow row = dataGridView1.SelectedRows[0];
                Int64 CustomerID = Convert.ToInt64(row.Cells[0].Value);

                System.Data.OleDb.OleDbCommandBuilder cb;
                cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

                cashOrdersDS = new DataSet();
                cashOrdersTable = new DataTable();
                cashOrdersTable.TableName = "cashOrders";
                cashOrdersDS.Tables.Add(cashOrdersTable);

                //cashCustom.Open();
                //cashCustom.Close();

                String PrintedOrdersSQL = "SELECT ID, QTY, Description, Supplier, Date, Cost, Sell, CashAccountRef_FKID from cashOrders INNER JOIN PrintedCustomers ON cashOrders.cashAccountRef_FKID=PrintedCustomers.PrintedAccRef WHERE PrintedCustomers.PrintedAccRef = " + CustomerID.ToString();
                cashDA = new System.Data.OleDb.OleDbDataAdapter(PrintedOrdersSQL, cashCustom);
                cashDA.Fill(cashOrdersTable);


                dataGridView2.DataSource = cashOrdersTable;
            }

cashOrdersTable will still remain a seperate entity in memory to the dataset, the dataset will simply create a copy of it in its own memory which you then refer to through the dataset.

SO I should do something like this??

 cashOrdersDS(cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);

Sorry.. Newbie stupid questions I know.. :(

Correct that should be done :)

You may also want to check all your code for such occurances and alwasy reference the dataset, will keep all changes in one place then.

Hi Mikey,

I thought that's what needed to be done but again I get an error. Possible a simple one this time?

Code:

           private void unbind()
        {
            dataGridView2.DataSource = null;
            dataGridView2.DataSource = cashOrdersTable;
        }

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


                if (dataGridView2.SelectedRows.Count > 0)
                {

                    cashOrdersDS(cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                    //cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                    cashCustom.Open();

                    unbind();
                    cashDA.Update(cashOrdersDS.Tables[0]);

                    cashCustom.Close();

                    MessageBox.Show("Record Deleted");
                }
                else
                {
                    MessageBox.Show("Please Select a row");
                }
            }

The Error is in the screenshot provided.

Oh crud sorry I skim read your last post and completely missed what the code actually was!

cashOrdersDS(cashOrdersTable.Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);

Replace with

cashOrdersDS.Tables[0].Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);

Hi Mikey,

This Programming lark can get a tad teasy can't it?! Sheesh!..

I've manipulated the code as requested. It does remove the line and run throug the update command fine but when seleting another account in the above section and then going back to the original account the order line re-appears once again.

Code being used for Delete Button:

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


            if (dataGridView2.SelectedRows.Count > 0)
            {

                cashOrdersDS.Tables[0].Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();

                cashDA.Update(cashOrdersDS.Tables[0]);

                cashCustom.Close();

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }

I've attached screenshots to show what's going on.

Right going back through the old questions, it shows the code is binding the data source of the grid to that lone data table, this is also the same in the unbind() method.

These will need to be updated to point to cashOrdersDS.Tables[0]

Hi Mikey

I've been through the entire Code changing the Datasources and Databind etc to point to the correct table in the cashDA 'dataset'.

Below is the FULL code just incase you are able to plonk it into your VStudio?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CardIndex_v2_2012
{
    public partial class Form1 : Form
    {

        private ADODB.Connection adoConn = new ADODB.Connection();
        private ADODB.Recordset adoRS = new ADODB.Recordset();

        //Access Database Adapater Information//

        System.Data.OleDb.OleDbConnection cashCustom = new System.Data.OleDb.OleDbConnection();
        System.Data.OleDb.OleDbDataAdapter cashDA = new System.Data.OleDb.OleDbDataAdapter();

        //Data Sets and Data Tables//
        DataSet cashCustomersDS;
        DataTable cashCustomersTable;

        DataSet cashOrdersDS;
        DataTable cashOrdersTable;


        DataSet printedCustomersDS;
        DataTable printedOrdersTable;
        private DataSet cashOrdersDs;



        public Form1()
        {
            InitializeComponent();

            //Opens Line 50 Connection//
            adoConn.Open("SageLine50v17", "Manager", "", 0);

            adoRS = adoConn.OpenSchema(ADODB.SchemaEnum.adSchemaTables, null, System.Reflection.Missing.Value);

            while (!(adoRS.EOF))
            {
                comboBox1.Items.Add(adoRS.Fields["TABLE_NAME"].Value.ToString());

                adoRS.MoveNext();
            }

            adoRS.Close();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Code Below Disables all Txt Boxes from Being Selected until a new account is ready to be inputted//
            txtBoxAccRef.Enabled = false;
            txtBoxAddr1.Enabled = false;
            txtBoxAddr2.Enabled = false;
            txtBoxCounty.Enabled = false;
            txtBoxName.Enabled = false;
            txtBoxPostCode.Enabled = false;
            txtBoxTown.Enabled = false;

            txtOrderQTY.Enabled = false;
            txtBoxDescrip.Enabled = false;
            txtBoxSupplier.Enabled = false;
            dateTimePicker1.Enabled = false;
            txtBoxCost.Enabled = false;
            txtBoxSell.Enabled = false;

            cashOrdersTable.TableName = "cashOrders";
        }

        private void radioBtnCash_CheckedChanged(object sender, EventArgs e)
        {
            //Following Code loads CashCustomers data Table from Database and puts into dataGridView1//
            cashCustom.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Orders.mdb";
            cashCustomersDS = new DataSet();
            cashCustomersTable = new DataTable();
            cashCustomersTable.TableName = "cashCustomers";
            cashCustomersDS.Tables.Add(cashCustomersTable);


            cashCustom.Open();

            String cashCustomerSQL = "SELECT * FROM cashCustomers";
            cashDA = new System.Data.OleDb.OleDbDataAdapter(cashCustomerSQL, cashCustom);
            cashDA.Fill(cashCustomersTable);

            dataGridView1.DataSource = cashCustomersTable;
            dataGridView1.Columns["CashAddress5"].Visible = false;
            dataGridView1.Columns["CashAddress3"].Visible = false;
            dataGridView1.Columns["CashAddress2"].Visible = false;
            dataGridView1.Columns["CashAddress1"].Visible = false;

            cashCustom.Close();

        }

        private void radioGroupBox_Enter(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

            //Checks to see which radio button is checked before running the SQL Scripts to populate the datagridviews//
            if (radioBtnCash.Checked == true)
            {

                //Below selects data from the Current Selected Row, finds out the cell value an populates the current text box//
                txtBoxAccRef.Text = dataGridView1.SelectedCells[0].Value.ToString();
                txtBoxName.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtBoxAddr1.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtBoxAddr2.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtBoxTown.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtBoxCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtBoxPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();
                textBox1.Text = txtBoxAccRef.Text;

                //////////Following code selects the row in the first grid, selects the ID, Stores it and runs SQL to match ID to populate 2nd dataGrid////////////

                //Selects the Row ID and stores in a INT Variable//
                DataGridViewRow row = dataGridView1.SelectedRows[0];
                Int64 CustomerID = Convert.ToInt64(row.Cells[0].Value);

                //Reconnects to the database//
                System.Data.OleDb.OleDbCommandBuilder cb;
                cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

                //Organises the DataSets and Datatables//
                cashOrdersDS = new DataSet();
                cashOrdersTable = new DataTable();
                cashCustomersTable.TableName = "cashOrders";
                cashOrdersDS.Tables.Add(cashOrdersTable);

                //Opens the Connection//
                //cashCustom.Open();
                //cashCustom.Close();

                //Takes the Stored SQL IN the String Vairable and uses the DataAdapter to run SQL on database connection//
                String cashOrdersSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN cashCustomers ON cashOrders.CashAccountRef_FKID=cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = " + CustomerID.ToString();
                cashDA = new System.Data.OleDb.OleDbDataAdapter(cashOrdersSQL, cashCustom);

                //Fills the Datatable with all the requires data//
                cashDA.Fill(cashOrdersTable);

                //Populates the datagridview2//
                dataGridView2.DataSource = cashOrdersDS.Tables[0];
            }

            else if (radioBtnPrinted.Checked == true)
            {
                //Below selects data from the Current Selected Row, finds out the cell value an populates the current text box//
                txtBoxAccRef.Text = dataGridView1.SelectedCells[0].Value.ToString();
                txtBoxName.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtBoxAddr1.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtBoxAddr2.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtBoxTown.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtBoxCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtBoxPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();

                DataGridViewRow row = dataGridView1.SelectedRows[0];
                Int64 CustomerID = Convert.ToInt64(row.Cells[0].Value);

                System.Data.OleDb.OleDbCommandBuilder cb;
                cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

                cashOrdersDS = new DataSet();
                cashOrdersTable = new DataTable();
                cashOrdersTable.TableName = "cashOrders";
                cashOrdersDS.Tables.Add(cashOrdersTable);

                //cashCustom.Open();
                //cashCustom.Close();

                String PrintedOrdersSQL = "SELECT ID, QTY, Description, Supplier, Date, Cost, Sell, CashAccountRef_FKID from cashOrders INNER JOIN PrintedCustomers ON cashOrders.cashAccountRef_FKID=PrintedCustomers.PrintedAccRef WHERE PrintedCustomers.PrintedAccRef = " + CustomerID.ToString();
                cashDA = new System.Data.OleDb.OleDbDataAdapter(PrintedOrdersSQL, cashCustom);
                cashDA.Fill(cashOrdersTable);


                dataGridView2.DataSource = cashOrdersDS.Tables[0];
            }


        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }

        private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
        {


        }

        private void radioBtnPrinted_CheckedChanged(object sender, EventArgs e)
        {
            //Following Code loads PrintedCustomers data Table from Database and puts into dataGridView1//
            System.Data.OleDb.OleDbCommandBuilder cbp;
            cbp = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

            printedCustomersDS = new DataSet();
            printedOrdersTable = new DataTable();
            printedCustomersDS.Tables.Add(printedOrdersTable);

            //cashCustom.Open();
            //cashCustom.Close();

            String printedCustomersSQL = "SELECT * FROM PrintedCustomers";
            cashDA = new System.Data.OleDb.OleDbDataAdapter(printedCustomersSQL, cashCustom);
            cashDA.Fill(printedOrdersTable);

            dataGridView1.DataSource = printedOrdersTable;
            dataGridView1.Columns["PrintedAddress5"].Visible = false;
            dataGridView1.Columns["PrintedAddress3"].Visible = false;
            dataGridView1.Columns["PrintedAddress2"].Visible = false;
            dataGridView1.Columns["PrintedAddress1"].Visible = false;

        }

        private void btnEditAcc_Click(object sender, EventArgs e)
        {
            //Enables to Text Boxes for any Edits that are needed//
            txtBoxAccRef.Enabled = true;
            txtBoxAddr1.Enabled = true;
            txtBoxAddr2.Enabled = true;
            txtBoxCounty.Enabled = true;
            txtBoxName.Enabled = true;
            txtBoxPostCode.Enabled = true;
            txtBoxTown.Enabled = true;
        }

        private void btnNewAcc_Click(object sender, EventArgs e)
        {
            //Enables Text Boxes//
            txtBoxAccRef.Enabled = true;
            txtBoxAddr1.Enabled = true;
            txtBoxAddr2.Enabled = true;
            txtBoxCounty.Enabled = true;
            txtBoxName.Enabled = true;
            txtBoxPostCode.Enabled = true;
            txtBoxTown.Enabled = true;

            //Clears Text Boxes//
            txtBoxAccRef.Clear();
            txtBoxAddr1.Clear();
            txtBoxAddr2.Clear();
            txtBoxCounty.Clear();
            txtBoxName.Clear();
            txtBoxPostCode.Clear();
            txtBoxTown.Clear();


        }

        private void btnSaveAcc_Click(object sender, EventArgs e)
        {

            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);


            DataRow DR = cashCustomersDS.Tables[0].NewRow();

            DR["CashAccRef"] = Int64.Parse(txtBoxAccRef.Text);
            DR["CashName"] = txtBoxName.Text.ToString();
            DR["CashAddress1"] = txtBoxAddr1.Text.ToString();
            DR["CashAddress2"] = txtBoxAddr2.Text.ToString();
            DR["CashTown"] = txtBoxTown.Text.ToString();
            DR["CashAddress3"] = txtBoxCounty.Text.ToString();
            DR["CashAddress5"] = txtBoxPostCode.Text.ToString();

            cashCustomersDS.Tables[0].Rows.Add(DR);

            cashDA.Update(cashCustomersDS, "cashCustomers");

            MessageBox.Show("Customer Added");
        }

        private void radioBtnAcc_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {



            txtOrderQTY.Text = dataGridView2.SelectedCells[1].Value.ToString();
            txtBoxDescrip.Text = dataGridView2.SelectedCells[2].Value.ToString();
            txtBoxSupplier.Text = dataGridView2.SelectedCells[3].Value.ToString();
            dateTimePicker1.Text = dataGridView2.SelectedCells[4].Value.ToString();
            txtBoxCost.Text = dataGridView2.SelectedCells[6].Value.ToString();
            txtBoxSell.Text = dataGridView2.SelectedCells[6].Value.ToString();



        }

        private void btnOrderNew_Click(object sender, EventArgs e)
        {
            txtOrderQTY.Enabled = true;
            txtBoxDescrip.Enabled = true;
            txtBoxSupplier.Enabled = true;
            dateTimePicker1.Enabled = true;
            txtBoxCost.Enabled = true;
            txtBoxSell.Enabled = true;
            btnEditOrder.Enabled = false;
            btnOrderEdit.Enabled = false;
            txtOrderQTY.Clear();
            txtBoxDescrip.Clear();
            txtBoxSupplier.Clear();
            txtBoxCost.Clear();
            txtBoxSell.Clear();
        }

        private void btnOrderEdit_Click(object sender, EventArgs e)
        {
                   int i, j;

            i = dataGridView2.CurrentCell.RowIndex;
            j = dataGridView2.CurrentRow.Index;

            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

            DataRow dRow2 = cashOrdersDS.Tables["cashOrders"].Rows[0];

            dRow2["cashQTY"] = Int64.Parse(txtOrderQTY.Text);
            dRow2["cashDescription"] = txtBoxDescrip.Text.ToString();
            dRow2["cashSupplier"] = txtBoxSupplier.Text.ToString();
            dRow2["cashDate"] = dateTimePicker1.Value.ToString();
            dRow2["cashCost"] = Convert.ToDouble(txtBoxCost.Text);
            dRow2["cashSell"] = Convert.ToDouble(txtBoxSell.Text);
            dRow2["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);

            cashDA.Update(cashOrdersDS, "cashOrders");

            MessageBox.Show("Data Updated");

        }

        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["cashQTY"] = Int64.Parse(txtOrderQTY.Text);
            DRO["cashDescription"] = txtBoxDescrip.Text.ToString();
            DRO["cashSupplier"] = txtBoxSupplier.Text.ToString();
            DRO["cashDate"] = dateTimePicker1.Value.ToString();
            DRO["cashCost"] = Convert.ToDouble(txtBoxCost.Text);
            DRO["cashSell"] = Convert.ToDouble(txtBoxSell.Text);
            DRO["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);


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




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

            MessageBox.Show("New Order Line Added.");
        }

        private void btnEditOrder_Click(object sender, EventArgs e)
        {
            txtOrderQTY.Enabled = true;
            txtBoxDescrip.Enabled = true;
            txtBoxSupplier.Enabled = true;

            dateTimePicker1.Enabled = true;
            txtBoxCost.Enabled = true;
            txtBoxSell.Enabled = true;
            btnOrderSave.Enabled = false;
        }


        private void unbind()
    {
        dataGridView2.DataSource = null;
        dataGridView2.DataSource = cashOrdersDS.Tables[0];
    }

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


            if (dataGridView2.SelectedRows.Count > 0)
            {

                cashOrdersDS.Tables[0].Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();

                cashDA.Update(cashOrdersDS.Tables[0]);

                cashCustom.Close();

                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }
    }

}

I have made some changed to your code, highlighted with triple comment blocks surrounded with #'s.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CardIndex_v2_2012
{
    public partial class Form1 : Form
    {
        private ADODB.Connection adoConn = new ADODB.Connection();
        private ADODB.Recordset adoRS = new ADODB.Recordset();
        //Access Database Adapater Information//
        System.Data.OleDb.OleDbConnection cashCustom = new System.Data.OleDb.OleDbConnection();
        System.Data.OleDb.OleDbDataAdapter cashDA = new System.Data.OleDb.OleDbDataAdapter();
        //Data Sets and Data Tables//
        /// ###########################################################
        /// Removed the now-redundant data tables and an unused private dataset, change #1
        /// ###########################################################
        DataSet cashCustomersDS;
        DataSet cashOrdersDS;
        DataSet printedCustomersDS;

        public Form1()
        {
            InitializeComponent();
            //Opens Line 50 Connection//
            adoConn.Open("SageLine50v17", "Manager", "", 0);
            adoRS = adoConn.OpenSchema(ADODB.SchemaEnum.adSchemaTables, null, System.Reflection.Missing.Value);
            while (!(adoRS.EOF))
            {
                comboBox1.Items.Add(adoRS.Fields["TABLE_NAME"].Value.ToString());
                adoRS.MoveNext();
            }
            adoRS.Close();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //Code Below Disables all Txt Boxes from Being Selected until a new account is ready to be inputted//
            txtBoxAccRef.Enabled = false;
            txtBoxAddr1.Enabled = false;
            txtBoxAddr2.Enabled = false;
            txtBoxCounty.Enabled = false;
            txtBoxName.Enabled = false;
            txtBoxPostCode.Enabled = false;
            txtBoxTown.Enabled = false;
            txtOrderQTY.Enabled = false;
            txtBoxDescrip.Enabled = false;
            txtBoxSupplier.Enabled = false;
            dateTimePicker1.Enabled = false;
            txtBoxCost.Enabled = false;
            txtBoxSell.Enabled = false;
            cashOrdersTable.TableName = "cashOrders";
        }
        private void radioBtnCash_CheckedChanged(object sender, EventArgs e)
        {
            //Following Code loads CashCustomers data Table from Database and puts into dataGridView1//
            cashCustom.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Orders.mdb";
            /// ###########################################################
            /// Removed the data table and created it directly into the dataset and updated bindings accordingly for dataset, change #2
            /// ###########################################################
            cashCustomersDS = new DataSet();
            cashCustomersDS.Tables.Add("cashCustomers");
            cashCustom.Open();
            String cashCustomerSQL = "SELECT * FROM cashCustomers";
            cashDA = new System.Data.OleDb.OleDbDataAdapter(cashCustomerSQL, cashCustom);
            cashDA.Fill(cashCustomersDS.Tables["cashCustomers"]);
            dataGridView1.DataSource = cashCustomersDS.Tables["cashCustomers"];
            dataGridView1.Columns["CashAddress5"].Visible = false;
            dataGridView1.Columns["CashAddress3"].Visible = false;
            dataGridView1.Columns["CashAddress2"].Visible = false;
            dataGridView1.Columns["CashAddress1"].Visible = false;
            cashCustom.Close();
        }
        private void radioGroupBox_Enter(object sender, EventArgs e)
        {
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Checks to see which radio button is checked before running the SQL Scripts to populate the datagridviews//
            if (radioBtnCash.Checked == true)
            {
                //Below selects data from the Current Selected Row, finds out the cell value an populates the current text box//
                txtBoxAccRef.Text = dataGridView1.SelectedCells[0].Value.ToString();
                txtBoxName.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtBoxAddr1.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtBoxAddr2.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtBoxTown.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtBoxCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtBoxPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();
                textBox1.Text = txtBoxAccRef.Text;
                //////////Following code selects the row in the first grid, selects the ID, Stores it and runs SQL to match ID to populate 2nd dataGrid////////////
                //Selects the Row ID and stores in a INT Variable//
                DataGridViewRow row = dataGridView1.SelectedRows[0];
                Int64 CustomerID = Convert.ToInt64(row.Cells[0].Value);
                //Reconnects to the database//
                System.Data.OleDb.OleDbCommandBuilder cb;
                cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
                //Organises the DataSets and Datatables//
                /// ###########################################################
                /// Removed the data table and created it directly into the dataset and updated bindings accordingly for dataset, change #3
                /// ###########################################################
                cashOrdersDS = new DataSet();
                cashOrdersDS.Tables.Add("cashOrders");
                //Opens the Connection//
                //cashCustom.Open();
                //cashCustom.Close();
                //Takes the Stored SQL IN the String Vairable and uses the DataAdapter to run SQL on database connection//
                String cashOrdersSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN cashCustomers ON cashOrders.CashAccountRef_FKID=cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = " + CustomerID.ToString();
                cashDA = new System.Data.OleDb.OleDbDataAdapter(cashOrdersSQL, cashCustom);
                //Fills the Datatable with all the requires data//
                cashDA.Fill(cashOrdersDS.Tables["cashOrders"]);
                //Populates the datagridview2//
                dataGridView2.DataSource = cashOrdersDS.Tables["cashOrders"];
            }
            else if (radioBtnPrinted.Checked == true)
            {
                //Below selects data from the Current Selected Row, finds out the cell value an populates the current text box//
                txtBoxAccRef.Text = dataGridView1.SelectedCells[0].Value.ToString();
                txtBoxName.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtBoxAddr1.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtBoxAddr2.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtBoxTown.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtBoxCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtBoxPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();
                DataGridViewRow row = dataGridView1.SelectedRows[0];
                Int64 CustomerID = Convert.ToInt64(row.Cells[0].Value);
                System.Data.OleDb.OleDbCommandBuilder cb;
                cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
                /// ###########################################################
                /// Removed the data table and created it directly into the dataset and updated bindings accordingly for dataset, change #4
                /// ###########################################################
                cashOrdersDS = new DataSet();
                cashOrdersDS.Tables.Add("cashOrders");
                //cashCustom.Open();
                //cashCustom.Close();
                String PrintedOrdersSQL = "SELECT ID, QTY, Description, Supplier, Date, Cost, Sell, CashAccountRef_FKID from cashOrders INNER JOIN PrintedCustomers ON cashOrders.cashAccountRef_FKID=PrintedCustomers.PrintedAccRef WHERE PrintedCustomers.PrintedAccRef = " + CustomerID.ToString();
                cashDA = new System.Data.OleDb.OleDbDataAdapter(PrintedOrdersSQL, cashCustom);
                cashDA.Fill(cashOrdersDS.Tables["cashOrders"]);
                dataGridView2.DataSource = cashOrdersDS.Tables["cashOrders"];
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }
        private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
        }
        private void radioBtnPrinted_CheckedChanged(object sender, EventArgs e)
        {
            //Following Code loads PrintedCustomers data Table from Database and puts into dataGridView1//
            System.Data.OleDb.OleDbCommandBuilder cbp;
            cbp = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            /// ###########################################################
            /// Removed the data table and created it directly into the dataset and updated bindings accordingly for dataset, change #5
            /// ###########################################################
            printedCustomersDS = new DataSet();
            printedCustomersDS.Tables.Add("printedOrders");
            //cashCustom.Open();
            //cashCustom.Close();
            String printedCustomersSQL = "SELECT * FROM PrintedCustomers";
            cashDA = new System.Data.OleDb.OleDbDataAdapter(printedCustomersSQL, cashCustom);
            cashDA.Fill(printedCustomersDS.Tables["printedOrders"]);
            dataGridView1.DataSource = printedCustomersDS.Tables["printedOrders"];
            dataGridView1.Columns["PrintedAddress5"].Visible = false;
            dataGridView1.Columns["PrintedAddress3"].Visible = false;
            dataGridView1.Columns["PrintedAddress2"].Visible = false;
            dataGridView1.Columns["PrintedAddress1"].Visible = false;
        }
        private void btnEditAcc_Click(object sender, EventArgs e)
        {
            //Enables to Text Boxes for any Edits that are needed//
            txtBoxAccRef.Enabled = true;
            txtBoxAddr1.Enabled = true;
            txtBoxAddr2.Enabled = true;
            txtBoxCounty.Enabled = true;
            txtBoxName.Enabled = true;
            txtBoxPostCode.Enabled = true;
            txtBoxTown.Enabled = true;
        }
        private void btnNewAcc_Click(object sender, EventArgs e)
        {
            //Enables Text Boxes//
            txtBoxAccRef.Enabled = true;
            txtBoxAddr1.Enabled = true;
            txtBoxAddr2.Enabled = true;
            txtBoxCounty.Enabled = true;
            txtBoxName.Enabled = true;
            txtBoxPostCode.Enabled = true;
            txtBoxTown.Enabled = true;
            //Clears Text Boxes//
            txtBoxAccRef.Clear();
            txtBoxAddr1.Clear();
            txtBoxAddr2.Clear();
            txtBoxCounty.Clear();
            txtBoxName.Clear();
            txtBoxPostCode.Clear();
            txtBoxTown.Clear();
        }
        private void btnSaveAcc_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            DataRow DR = cashCustomersDS.Tables[0].NewRow();
            DR["CashAccRef"] = Int64.Parse(txtBoxAccRef.Text);
            DR["CashName"] = txtBoxName.Text.ToString();
            DR["CashAddress1"] = txtBoxAddr1.Text.ToString();
            DR["CashAddress2"] = txtBoxAddr2.Text.ToString();
            DR["CashTown"] = txtBoxTown.Text.ToString();
            DR["CashAddress3"] = txtBoxCounty.Text.ToString();
            DR["CashAddress5"] = txtBoxPostCode.Text.ToString();
            /// ###########################################################
            /// Changed from pointing at table [0] to name for consistency, change #6
            /// ###########################################################
            cashCustomersDS.Tables["cashCustomers"].Rows.Add(DR);
            /// ###########################################################
            /// Added connection open and close around the update call, change #7
            /// ###########################################################
            cashCustom.Open();
            cashDA.Update(cashCustomersDS, "cashCustomers");
            cashCustom.Close();
            MessageBox.Show("Customer Added");
        }
        private void radioBtnAcc_CheckedChanged(object sender, EventArgs e)
        {
        }
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            txtOrderQTY.Text = dataGridView2.SelectedCells[1].Value.ToString();
            txtBoxDescrip.Text = dataGridView2.SelectedCells[2].Value.ToString();
            txtBoxSupplier.Text = dataGridView2.SelectedCells[3].Value.ToString();
            dateTimePicker1.Text = dataGridView2.SelectedCells[4].Value.ToString();
            txtBoxCost.Text = dataGridView2.SelectedCells[6].Value.ToString();
            txtBoxSell.Text = dataGridView2.SelectedCells[6].Value.ToString();
        }
        private void btnOrderNew_Click(object sender, EventArgs e)
        {
            txtOrderQTY.Enabled = true;
            txtBoxDescrip.Enabled = true;
            txtBoxSupplier.Enabled = true;
            dateTimePicker1.Enabled = true;
            txtBoxCost.Enabled = true;
            txtBoxSell.Enabled = true;
            btnEditOrder.Enabled = false;
            btnOrderEdit.Enabled = false;
            txtOrderQTY.Clear();
            txtBoxDescrip.Clear();
            txtBoxSupplier.Clear();
            txtBoxCost.Clear();
            txtBoxSell.Clear();
        }
        private void btnOrderEdit_Click(object sender, EventArgs e)
        {
            int i, j;
            i = dataGridView2.CurrentCell.RowIndex;
            j = dataGridView2.CurrentRow.Index;
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            DataRow dRow2 = cashOrdersDS.Tables["cashOrders"].Rows[0];
            dRow2["cashQTY"] = Int64.Parse(txtOrderQTY.Text);
            dRow2["cashDescription"] = txtBoxDescrip.Text.ToString();
            dRow2["cashSupplier"] = txtBoxSupplier.Text.ToString();
            dRow2["cashDate"] = dateTimePicker1.Value.ToString();
            dRow2["cashCost"] = Convert.ToDouble(txtBoxCost.Text);
            dRow2["cashSell"] = Convert.ToDouble(txtBoxSell.Text);
            dRow2["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);
            /// ###########################################################
            /// Re-added dRow2 to the dataset after population else it does absolutely nothing, change #8
            /// ###########################################################
            cashOrdersDS.Tables["cashOrders"].Rows.Add(dRow2);
            /// ###########################################################
            /// Added connection open and close around the update call, change #9
            /// ###########################################################
            cashCustom.Open();
            cashDA.Update(cashOrdersDS, "cashOrders");
            cashCustom.Close();
            MessageBox.Show("Data Updated");
        }
        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["cashQTY"] = Int64.Parse(txtOrderQTY.Text);
            DRO["cashDescription"] = txtBoxDescrip.Text.ToString();
            DRO["cashSupplier"] = txtBoxSupplier.Text.ToString();
            DRO["cashDate"] = dateTimePicker1.Value.ToString();
            DRO["cashCost"] = Convert.ToDouble(txtBoxCost.Text);
            DRO["cashSell"] = Convert.ToDouble(txtBoxSell.Text);
            DRO["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);
            cashOrdersDS.Tables["cashOrders"].Rows.Add(DRO);
            /// ###########################################################
            /// Added connection open and close around the update call, change #10
            /// ###########################################################
            cashCustom.Open();
            cashDA.Update(cashOrdersDS.Tables["cashOrders"]);
            cashCustom.Close();
            MessageBox.Show("New Order Line Added.");
        }
        private void btnEditOrder_Click(object sender, EventArgs e)
        {
            txtOrderQTY.Enabled = true;
            txtBoxDescrip.Enabled = true;
            txtBoxSupplier.Enabled = true;
            dateTimePicker1.Enabled = true;
            txtBoxCost.Enabled = true;
            txtBoxSell.Enabled = true;
            btnOrderSave.Enabled = false;
        }
        private void unbind()
        {
            /// ###########################################################
            /// Added suspend and resume layout for better visual refresh on form with large amounts of data, change #11
            /// ###########################################################
            dataGridView2.SuspendLayout();
            dataGridView2.DataSource = null;
            dataGridView2.DataSource = cashOrdersDS.Tables[0];
            dataGridView2.ResumeLayout();
        }
        private void btnOrderDelete_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            if (dataGridView2.SelectedRows.Count > 0)
            {
                /// ###########################################################
                /// Changed from table [0] to table name for consistency, change #12
                /// ###########################################################
                cashOrdersDS.Tables["cashOrders"].Rows.RemoveAt(dataGridView2.SelectedRows[0].Index);
                cashCustom.Open();
                cashDA.Update(cashOrdersDS.Tables["cashOrders"]);
                cashCustom.Close();
                MessageBox.Show("Record Deleted");
            }
            else
            {
                MessageBox.Show("Please Select a row");
            }
        }
    }
}

If you want an explanation further on any change or if i made new bugs let me know as none of the changes are tested at run time but should be fine.

Wow! Thank you very much for looking at this for me Mikey, That's really nice of you.

Ok.. I've now made the adjustments needed and I think there's a few litle niggles that need working out still.

Issue 1:
The Delete button will remove it from the dataset but still will not update the backend tables. There is no error message anymore. just when I select another customer account in gridview1 and then go back to the original the order line has re-appeared.

Issue 2:
When selecting the Printed Customers Radio button the Customers list loads up correctly by when selecting there account to show the Orders the code Errors. (See attached Screenshot).

Issue 3:
When attempting to update the Sales Order Record via the Text Box Values the Code Errors. (see attached Screenshot).

There a few more little niggles which I'm tryin to resolve but these are the one's I have found so far.

One clarification, in the edit code:

        private void btnOrderEdit_Click(object sender, EventArgs e)
        {
            int i, j;
            i = dataGridView2.CurrentCell.RowIndex;
            j = dataGridView2.CurrentRow.Index;
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);
            DataRow dRow2 = cashOrdersDS.Tables["cashOrders"].Rows[0];
            dRow2["cashQTY"] = Int64.Parse(txtOrderQTY.Text);
            dRow2["cashDescription"] = txtBoxDescrip.Text.ToString();
            dRow2["cashSupplier"] = txtBoxSupplier.Text.ToString();
            dRow2["cashDate"] = dateTimePicker1.Value.ToString();
            dRow2["cashCost"] = Convert.ToDouble(txtBoxCost.Text);
            dRow2["cashSell"] = Convert.ToDouble(txtBoxSell.Text);
            dRow2["cashAccountRef_FKID"] = Int64.Parse(textBox1.Text);
            /// ###########################################################
            /// Re-added dRow2 to the dataset after population else it does absolutely nothing, change #8
            /// ###########################################################
            cashOrdersDS.Tables["cashOrders"].Rows.Add(dRow2);
            /// ###########################################################
            /// Added connection open and close around the update call, change #9
            /// ###########################################################
            cashCustom.Open();
            cashDA.Update(cashOrdersDS, "cashOrders");
            cashCustom.Close();
            MessageBox.Show("Data Updated");
        }

On line 8 it sets dRow2 to a specific row (always the first in table) is this intentional? As surely it will always just edit that one entry. Should it not be off a selected index or something?

Hi Mikey,

I believe your right.. It should edit the selected row. How Would I ammend that line of code exactly? I've looked into the intell-sense and cannot find 'selectedIndex' or anything like that? :S I must be doing it wrong somewhere.

Ummm which datagrid is it edited off?

datagridview2

Hmmm does this fix the edit issue?

private void btnOrderEdit_Click(object sender, EventArgs e)
        {
            int i, j;
            i = dataGridView2.CurrentCell.RowIndex;
            j = dataGridView2.CurrentRow.Index;
            System.Data.OleDb.OleDbCommandBuilder cb;
            cb = new System.Data.OleDb.OleDbCommandBuilder(cashDA);

            /// ###########################################################
            /// Changed so it edits directly into the DGV which in turn should edit the dataset behind it, change #13
            /// ###########################################################
            dataGridView2.SelectedRows[0].Cells["cashQTY"].Value = Int64.Parse(txtOrderQTY.Text);
            dataGridView2.SelectedRows[0].Cells["cashDescription"].Value = txtBoxDescrip.Text.ToString();
            dataGridView2.SelectedRows[0].Cells["cashSupplier"].Value = txtBoxSupplier.Text.ToString();
            dataGridView2.SelectedRows[0].Cells["cashDate"].Value = dateTimePicker1.Value.ToString();
            dataGridView2.SelectedRows[0].Cells["cashCost"].Value = Convert.ToDouble(txtBoxCost.Text);
            dataGridView2.SelectedRows[0].Cells["cashSell"].Value = Convert.ToDouble(txtBoxSell.Text);
            dataGridView2.SelectedRows[0].Cells["cashAccountRef_FKID"].Value = Int64.Parse(textBox1.Text);
            /// ###########################################################
            /// Added connection open and close around the update call, change #9
            /// ###########################################################
            cashCustom.Open();
            cashDA.Update(cashOrdersDS, "cashOrders");
            cashCustom.Close();
            MessageBox.Show("Data Updated");
        }

Hi Mikey,

This code updates the Grid view but when moving off the selected row and selecting another account it goes back to the original value. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.