Hi guys, I hope someone can help. I have a list view being populated by a Table (cashCustomers) in an Access DB which has customers Information.
- CashAccRef
- CashName
- CashAddress1
- CashAddress2
- CashTown
- CashAddress3
- CashAddress4
- CashAddress5
and the following Orders table (cashOrders)
- ID
- QTY
- Description
- Supplier
- Date
- Cost
- Sell
- cashAccountRef_FKID
I am basically try set it so when 'listview1_MouseClick' is activated by selecting an account in the 1st list view, the second listview 'listview2' populates with the correct order lines per customer.
Currently I believe I have to use a INNER JOIN Querey which I had done (Code Below):
cashOrders = new DataSet();
cashOrderTable = new DataTable();
cashOrders.Tables.Add(cashOrderTable);
string sql2 = "SELECT ID,QTY,Description,Supplier,Date,Cost,Sell from cashOrders INNER JOIN cashCustomers ON cashOrders.cashAccountRef_FKID=cashCustomers.CashAccRef;";
cashDA = new System.Data.OleDb.OleDbDataAdapter(sql2, cashCustom);
cashDA.Fill(cashOrderTable);
foreach (DataRow myRow2 in cashOrderTable.Rows)
{
listView2.Items.Add(myRow2[0].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[1].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[2].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[3].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[4].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[5].ToString());
listView2.Items[listView2.Items.Count - 1].SubItems.Add(myRow2[6].ToString());
}
However, I can guess it need to know the selection I made in 'Listview1'. How do I go about amending the String to pickup the selection in 'listview1'?
also currently when running this I do get an error on the cashDA.fill(cashOrderTable stating 'Type Mismatch in expression'.
Thanks for any help in advance.
Mark.