Multiple Tables Select into Crystal Report

melkanzi

Active member
Joined
Jul 9, 2006
Messages
29
Hi
Im trying to select from 3 tables Orders,Receipts and Customers. I get the records that I want throght SQL but when I attempt to view the data in Crystal Report I get na empty report.
Here is the code:
Code:
Dim con As New OleDb.OleDbConnection(My.Settings.KazaConstructionConnectionString)
        Dim ds As New DataSet

        Dim com As New OleDb.OleDbCommand("Select Receipts.ReceiptNumber,Customers.CustomerID,Customers.Name,Orders.OrderID,Orders.Normal,Orders.Resistant,Orders.Total,Orders.PaymentType,Orders.EmployeeName from Orders,Customers,Receipts where Customers.CustomerID=Orders.CustomerID and Customers.CustomerID=Receipts.CustomerID and Orders.OrderDate=#" & nowdate & "#", con)

        Dim da As New OleDb.OleDbDataAdapter(com.CommandText, con)
        Try
            con.Open()
            da.Fill(ds)
            con.Close()
        Catch ex As Exception

        End Try
        If ds.Tables(0).Rows.Count = 0 Then
            MessageBox.Show("There are no Orders made today", "No Orders", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        Dim rcpt As New DailyReport
        Dim rpt As New Reports
        rcpt.SetDataSource(ds.Tables(0))
        rpt.CRV.ReportSource = rcpt
        rpt.ShowDialog()
 
If you step through the code does the DataSet contain the correct data after the da.Fill(ds) line?

Also the line
Code:
Dim da As New OleDb.OleDbDataAdapter(com.CommandText, con)
would be better written as
Code:
Dim da As New OleDb.OleDbDataAdapter(com)
as it saves creating an extra command object.
 
Thanks for the reply,
It does get me the correct data when I read the data returned into the dataset I get the correct data. The problem is in Crystal Report
 
Thank you for the help Ive found the solution in another thread. All I had to do is write:
Report.Database.Tables(0).SetDatasource(ds.Tables(0))
Report.Database.Tables(1).SetDatasource(ds.Tables(1))

Thanks again
 
Back
Top