Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

I'm 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:

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()

  • Administrators
Posted

If you step through the code does the DataSet contain the correct data after the da.Fill(ds) line?

 

Also the line

Dim da As New OleDb.OleDbDataAdapter(com.CommandText, con)

would be better written as

Dim da As New OleDb.OleDbDataAdapter(com)

as it saves creating an extra command object.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Posted

Thank you for the help I've 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...