How do I create reports (using crystal reports) with data from multiple tables?
I created a Dataset with two tables in it and choosed that Dataset in the Database Expert wizard's Project Data->ADO.NET DataSets on the Add/Remove Database menu of the crystal report designer.
I drag some fields from that two tables to the crystal report designer.
Now, I create a query to the two tables then I fill the Dataset with rows from that query and set the CrystalReport.SetDataSource() to my Dataset, I also set the CrystalReportViewer.ReportSource to my CrystalReport. But the CrystalReportViewer didnt display the data.
It works when I query one table only.
Here's the code:
Dim Rpt As New CrystalReport1()
dsStudentAccount.Clear()
daStudentAccount.SelectCommand.CommandText = "SELECT * FROM student " & _
"INNER JOIN account ON student.StudentNumber = account.StudentNumber"
daStudentAccount.Fill(dsStudentAccount)
Rpt.SetDataSource(dsStudentAccount)
CrystalReportViewer1.ReportSource = Rpt
I created a Dataset with two tables in it and choosed that Dataset in the Database Expert wizard's Project Data->ADO.NET DataSets on the Add/Remove Database menu of the crystal report designer.
I drag some fields from that two tables to the crystal report designer.
Now, I create a query to the two tables then I fill the Dataset with rows from that query and set the CrystalReport.SetDataSource() to my Dataset, I also set the CrystalReportViewer.ReportSource to my CrystalReport. But the CrystalReportViewer didnt display the data.
It works when I query one table only.
Here's the code:
Dim Rpt As New CrystalReport1()
dsStudentAccount.Clear()
daStudentAccount.SelectCommand.CommandText = "SELECT * FROM student " & _
"INNER JOIN account ON student.StudentNumber = account.StudentNumber"
daStudentAccount.Fill(dsStudentAccount)
Rpt.SetDataSource(dsStudentAccount)
CrystalReportViewer1.ReportSource = Rpt