Crystal Reports and JOIN SQL

Hi All

I have been stuck on this problem for a week and read every example on the web
I have 2 tables and I have generated a SQL Join Statement that fills a dataset
I display this in a datagrid and all is ok

However when I attempt to push this to the crystal reports object
I get a cross join which does not have any of the criteria applied


The code I execute to generate the dataset is as follows.
Two tables concerned are CustomerInvoices and CustomerAccounts
PK of CustomerInvoices is: UniqueInvoiceID
PK of CustomerAccounts is: UniqueInvoiceID  and PaymentNumber

Its like a parent- weak entity relationship
1 invoice many accounts

sqlstr = " SELECT CustomerInvoices.InvoiceID , CustomerInvoices.CustomerID , " +" CustomerInvoices.CustomerName , CustomerAccounts.DateOfPayment , CustomerAccounts.Payment , " + _" CustomerAccounts.PaymentMethod " + _" FROM CustomerAccounts INNER JOIN " + _" CustomerInvoices ON CustomerAccounts.UniqueInvoiceID = CustomerInvoices.UniqueInvoiceID "
 

Dim Sqladapter As SqlDataAdapter

connection = createDatabaseConnection()

dim
receivablesDataSet = New DataSet("DATASETNAME")

Sqladapter = New SqlDataAdapter(sqlstr, connection)

Sqladapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

Sqladapter.Fill(receivablesDataSet ) 
Dim newForm As New GenericCrystalViewerForm

Dim rpt As New CrystalReport2

rpt.SetDataSource(myDataSet)

GenericCrystalReportViewer.ReportSource = rpt


I dont want to use XML as it gives me an error saying I have a Invalid Key Node
and its driving me crazy

All I want to use is the simple setDataSource method.
By the way I have used all combinations such as
rpt.Database.Tables(1).SetDataSource(myDataSet.Tables(0))
with no luck at all

In summary:
Instead of getting 95 rowsfor example I am getting 65000 rows
which looks like a crossjoin
I would appreciate any help please
Thanks
Touraj



 



Answer this question

Crystal Reports and JOIN SQL

  • Learning WPF

    Hello did you solve this issue I have the same problem seem that the report is performing the cartesian product, my data set returns 4 record and when I pass it to the Crystal Report it show 16. I have checked the link method between both tables and is correct.

    Thanks



  • TonyRusin

    Hello Touraj,

    How did you create this report Was it based off of the same schema as the dataset you are pushing into the report

    If you right click on the report and select Database|Database Expert then click on the links tab, this will show you the links for the tables in your data set.  You can go through this by clicking on the link and then choosing link options.

    Changes made here should be saved with the report.

    Keith - Business Objects

  • Crystal Reports and JOIN SQL