获取这三个数据集并将其放入一个数据集以进入printReport(ds)函数的正确方法是什么?我不正确地做我的数据集,我只需要使用一个吗?我该如何修复此代码?
Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
Dim cmd As New SqlCommand("Select CustomerName, ShipAddress1, ShipAddress2, ShipCity, ShipToState, ShipToZip FROM Customers Where CustomerID = @CustomerID", con)
cmd.Parameters.Add("@CustomerID", SqlDbType.VarChar).Value = cboCustomer.Text
Dim cmd1 As New SqlCommand("Select * from LineTable where ID = @ID", con)
cmd1.Parameters.Add("@ID", SqlDbType.Int).Value = NextID
Dim cmd2 As New SqlCommand("Select * FROM HeaderTable where ID = @ID", con)
cmd2.Parameters.Add("@ID", SqlDbType.Int).Value = NextID
Dim ds As New DataSet()
Dim adap As New SqlDataAdapter(cmd)
Dim adap1 As New SqlDataAdapter(cmd1)
Dim adap2 As New SqlDataAdapter(cmd2)
If con.State = ConnectionState.Closed Then con.Open()
adap.Fill(ds, "Customers")
adap1.Fill(ds, "LineTable")
adap2.Fill(ds, "HeaderTable")
con.Close()
PrintReport(ds)
end sub
Private Sub printReport(ByVal ds As DataSet)
Dim newprintReport As New PrintReport(ds)
newprintReport.ShowDialog()
End Sub