PDA

Click to See Complete Forum and Search --> : Report based on multiple tables


bodylojohn
Jul 4th, 2008, 08:06 AM
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:

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?

rasinc
Jul 4th, 2008, 08:31 PM
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.

bodylojohn
Jul 8th, 2008, 12:18 PM
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:
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

Besoup
Jul 8th, 2008, 12:27 PM
where is BedrijfsgegevensOverzicht_DataSet1 being created?

bodylojohn
Jul 8th, 2008, 01:06 PM
where is BedrijfsgegevensOverzicht_DataSet1 being created?

I dragged it on the form from components.

Besoup
Jul 8th, 2008, 01:16 PM
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?

bodylojohn
Jul 9th, 2008, 12:30 AM
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.

Besoup
Jul 9th, 2008, 05:36 AM
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.

bodylojohn
Jul 9th, 2008, 06:46 AM
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?

Besoup
Jul 9th, 2008, 06:57 AM
not sure... what version of CR are you using?

bodylojohn
Jul 9th, 2008, 08:07 AM
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

bodylojohn
Jul 11th, 2008, 12:45 AM
Can anybody please help me?