Results 1 to 12 of 12

Thread: Report based on multiple tables

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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?

  2. #2
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Report based on multiple tables

    where is BedrijfsgegevensOverzicht_DataSet1 being created?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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.

  6. #6
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    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?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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.

  8. #8
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    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.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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?

  10. #10
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Report based on multiple tables

    not sure... what version of CR are you using?

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: Report based on multiple tables

    Can anybody please help me?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width