Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
blueangel
Starting Member
1 Post |
Posted - 2007-08-05 : 19:08:04
|
Hello all...I need help with displaying the following data. How can I get all the orders to display under the customers name. It only displays one line of data under the customer and it displays the customers name more than once each time with the order. Can someone tell me what's wrong. I'm getting the right orders but not sute how to display it. It's not grouping all the orders to the customer.Here is the code. Thanks much. Private Sub btnBills_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBills.Click Dim total As Double Dim subtotal As Double Dim i As Integer Dim fmtStr As String = "{0,-5} {1,10} {2,10} {3,12} " Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source = MICROLAND.MDB " Dim sqlStr As String = "SELECT * FROM Customers,Inventory,Orders WHERE Customers.custID = Orders.custID AND Inventory.itemID = Orders.itemID Order By Customers.custID" Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr) Dim dt As New DataTable Dim sum As Double dataAdapter.Fill(dt) dataAdapter.Dispose() For i = 0 To dt.Rows.Count - 1 lstResults.Items.Add(String.Format("MICROLAND INVOICE ")) lstResults.Items.Add(String.Format("BILL TO:" & dt.Rows(i)(1))) lstResults.Items.Add(String.Format(dt.Rows(i)(2))) lstResults.Items.Add(String.Format(dt.Rows(i)(3))) subtotal = dt.Rows(i)(7) * dt.Rows(i)(11) total = (total + subtotal) lstResults.Items.Add(String.Format(fmtStr, "QTY", "DESCRIPTION", "PRICE", "SUBTOTAL")) lstResults.Items.Add(String.Format(fmtStr, dt.Rows(i)(11), dt.Rows(i)(6), dt.Rows(i)(7), FormatCurrency(subtotal))) lstResults.Items.Add(vbTab & vbTab & vbTab & vbTab & "TOTAL:" & vbTab & FormatCurrency(total)) Next End SubEnd Class |
|
|
|
|
|
|