Hi guys,

I'm hoping you can help here with a problem I am having with regards to filling a Dataset.

It was working fine but have had to amend the code to read a different data set and structure.

Basics are 2 tables.. one customers, 1 orders. Joined on there Account Reference. SQL seems to be working correctly.

See below:

SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID=cashCustomers.CashAccRef WHERE cashCustomers.CashAccRefID = @HOME

But I get "No value given for one or more required parameters."

DB table layout seems correct. I'm sure Im just having a "Moment" but can anyone spot what I'm doing wrong.

Attached some screenshots as well

Thanks for any help in advance.

Regards
Mark.

Hmmm, can you post your sql for updating aswell and does that work? maybe you are providing parameters in the wrong order than you are in the one above. basically your trying to fill the dataset with the wrong order of parameters?

HI James,

Thanks for your reply. I've not got around to re-checking the 'Update command yet as I cannot get the 2nd DGV to populate with the Data as yet.

Also checked thed Tables Column names and they are in the correct order.

HI Pritaeas, I'm sorry - How do you mean?

The @Home Parameter is being picked up from a string.

See below for the whole code... upto where is errors on the DataSet 3:

           //If the Radio Button is checked the Script between the {} will be run//
            if (radioButton1.Checked == true)
            {
                //Looks at the row Selected in the GridView and then takes the Account Number and Stores in a Int64 called 'Customer ID'//
                DataGridViewRow drow = dataGridView1.SelectedRows[0];
                //Int64 CustomerID = Convert.ToInt64(drow.Cells[0].Value);
                string CustomID = Convert.ToString(drow.Cells[1].Value);

                //Sets the Selected Account and shows inside the Text Boxes on the right-hand side of the screen//
                txtAccRef.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtAccName.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtAccAddr1.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtAccAddr2.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtAccTown.Text = dataGridView1.SelectedCells[7].Value.ToString();
                txtAccPostCode.Text = dataGridView1.SelectedCells[5].Value.ToString();
                txtAccCounty.Text = dataGridView1.SelectedCells[6].Value.ToString();


                //Message to Test ID has been stored//
                //MessageBox.Show("Customer ID Stored");

                //Creates new versions of the Connection string and Data Set//
                con = new System.Data.OleDb.OleDbConnection();
                ds3 = new DataSet();

                //The actual connection to the database//                               //XML Path to Data Base held in string...sneaky like a Ninja!//
                con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" + textBox1.Text.ToString();

                //The SQL String you need to pass into the Data Adapter to collect the information//
                string OrdersCashCustomerSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID = cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = " + CustomID.ToString();

                da = new System.Data.OleDb.OleDbDataAdapter(OrdersCashCustomerSQL, con);

                //The Data Adapater (da) is told to fill the DataSet (ds) with the information pulled from the SQL Query and call this fill "cashCustomers"//
                da.Fill(ds3, "OrdersCashCustomers");

Regards
Mark

Hi Pritaes,

I think that is where I'm going wrong but not too sure how to get it right?

The end part of this Statement would need enclosing I guess?

"SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID = cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = " + CustomID.ToString();

Any pointers?
Mark B

//The SQL String you need to pass into the Data Adapter to collect the information//
string OrdersCashCustomerSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID = cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = '" + CustomID.ToString() + "'";

Hi Pritaes,

That seems to allow the code to follow through Pass the DataSet 3.

However, the DS3 seems to build the table needed but not values are inside?!

BUT... when i run the SQL Query in ACCESS 2010 against the DB the results are exactly what I'm looking for?!

Attached a Screenshot of the Empty DS. & Screenshot showing the Results of the SQL Query ran in ACCESS 2010.

OK... mr dumb-ass here.

Going back to basics I noticed the XML connection string was pointing to the wrong database!

(I have a few others all in different states of testing)

many thanks for all your help though.

regards
Mark

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.