Hello,
I am having a problem viewing data in a form from more than one table. I have read through a bunch of tutorials and MSDN files and whatnot but have not been able to nail down what i need to do.
Here is the code I have so far....it worked when I only needed to data from one table but now that I have introduced the second I have run into tons of problems. I am not sure if I need two DataAdapters and one DataSet or two DAs and two DSs. Does anyone see what I need to do with my code to get this to work?
I tried here to use 2 das and 1 ds...it did not work but maybe I have it set up wrong. When I run it the error always comes at
Brent
I am having a problem viewing data in a form from more than one table. I have read through a bunch of tutorials and MSDN files and whatnot but have not been able to nail down what i need to do.
Here is the code I have so far....it worked when I only needed to data from one table but now that I have introduced the second I have run into tons of problems. I am not sure if I need two DataAdapters and one DataSet or two DAs and two DSs. Does anyone see what I need to do with my code to get this to work?
Code:
Private Sub cmdfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfind.Click
write the query to get the data you want
Dim strhistory As String = "Select Invoicenumber, InvoiceDate, Total, CustomerNumber, BrokerID, LineSEQNo, ProductLine, COMM, Terms, Description, DiscountPercentage FROM PendingCommissions WHERE InvoiceNumber = " & txtinvnum.Text & " ORDER BY BrokerID, ProductLine DESC"
Dim strinvtotal As String = "SELECT InvoiceNumber, SUM(Total) AS InvTotal FROM InvoiceHistory WHERE InvoiceNumber = " & txtinvnum.Text & " GROUP BY InvoiceNumber"
Set up the data adapter and pass to it the sql statement and the connection
Dim daHistory As OleDbDataAdapter = New OleDbDataAdapter(strhistory, OleDbConnection1)
Dim dainvtotal As OleDbDataAdapter = New OleDbDataAdapter(strinvtotal, OleDbConnection1)
set the data set and fill it with data
Dim History As DataSet = New DataSet
daHistory.Fill(History, "PendingCommissions")
dainvtotal.Fill(History, "InvoiceHistory")
set the datatable
Dim dtH As DataTable = History.Tables("PendingCommissions")
Dim dtIT As DataTable = History.Tables("InvoiceHistory")
Finds the number of rows in a record and declares it
Dim rowtotal As Integer
rowtotal = dtH.Rows.Count
Dim First As Integer
Dim Last As Integer
First = 0
Last = rowtotal - 1
I tried here to use 2 das and 1 ds...it did not work but maybe I have it set up wrong. When I run it the error always comes at
Code:
dainvtotal.Fill(History, "InvoiceHistory")