Report based on multiple tables
Finally after a year I was able to make a report that is based on 1 table. This works. Before I explain my problem let me first tell you how I got my 1 table report to work.
I am using VB 2008 with an ACCESS 2007 database.
I made a form on wich I planted a crystal report viewer.
Then I created a new crytal report using the wizzard and used the ADO.NET datasets wich I am currently using in my programm.
So I selected a dataset and build the report.
Then..on the form where my crystal report viewer resides I inserted the following code:
Code:
Public Class testreports
Private Sub testreports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Land_DataSet.tblLAND' table. You can move, or remove it, as needed.
Me.tblLANDTableAdapter.Fill(Me.Land_DataSet.tblLAND)
Dim rpt As New testCRYSTALREPORT
rpt.SetDataSource(Land_DataSet)
Me.CrystalReportViewer1.ReportSource = rpt
End Sub
End Class
This works perfectly...
But now I want to make a report based on 2 or more tables but then it doenst work.
How do I go about this?
Re: Report based on multiple tables
I haven't used the Datasets yet myself but you would create a dataset with the correct tables and fields, similar to recordsets in VB6. Pull the data from the correct tables and then pass them to the report.
Re: Report based on multiple tables
I have created a query in my access 2007 database (qryBedrijfsgegevens) and created a report based on that query. First I added a dataset to the form the crystalreport viewer is on.
This is the code I use:
Code:
Public Class testreports
Private Sub testreports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Land_DataSet.tblLAND' table. You can move, or remove it, as needed.
Me.QryBEDRIJFSGEGEVENSTableAdapter1.Fill(Me.BedrijfsgegevensOverzicht_DataSet1.qryBEDRIJFSGEGEVENS)
Dim rpt1 As New test
rpt1.SetDataSource(BedrijfsgegevensOverzicht_DataSet1)
Me.CrystalReportViewer2.ReportSource = rpt1
End Sub
End Class
Now I get the following error: OLEDBExeption was unhandled
The error is traced to this line of code:
Me.QryBEDRIJFSGEGEVENSTableAdapter1.Fill(Me.BedrijfsgegevensOverzicht_DataSet1.qryBEDRIJFSGEGEVENS)
I realy hope somebody can help me
Re: Report based on multiple tables
where is BedrijfsgegevensOverzicht_DataSet1 being created?
Re: Report based on multiple tables
Quote:
Originally Posted by Besoup
where is BedrijfsgegevensOverzicht_DataSet1 being created?
I dragged it on the form from components.
Re: Report based on multiple tables
ok well I am pretty sure that you cannont just fill a dataset with another dataset... which would probably cause that problem.
From what I understand you're trying to display data from 2 seperate tables. Is there any relationship between the 2 tables?
Re: Report based on multiple tables
Quote:
Originally Posted by Besoup
ok well I am pretty sure that you cannont just fill a dataset with another dataset... which would probably cause that problem.
From what I understand you're trying to display data from 2 seperate tables. Is there any relationship between the 2 tables?
Indeed... I made a query in ms access 2007 and created a dataset from that query.
There is no relation defined between the 2 tables...but is that necessary?
Isnt there a tutorial of how to make and then connect to a crystal report?
I have googled for the last 2 months and came up with what I have so far.
Re: Report based on multiple tables
are you doing anything with the data in .net?
If you're not you should be able to connect the crystal report directly to the query in the access database.
Re: Report based on multiple tables
Quote:
Originally Posted by Besoup
are you doing anything with the data in .net?
If you're not you should be able to connect the crystal report directly to the query in the access database.
Is there a tutorial of how to do that?
Re: Report based on multiple tables
not sure... what version of CR are you using?
Re: Report based on multiple tables
Quote:
Originally Posted by Besoup
not sure... what version of CR are you using?
I am at work..
So I cant check right nog.
But the one that comes with Visual Studio 2008
Re: Report based on multiple tables
Can anybody please help me?