Results 1 to 5 of 5

Thread: Link DataGridView to CrystalDecisions Report

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    53

    Link DataGridView to CrystalDecisions Report

    In my Visual Basic 2010 project, I have a form named "frmViewReport" containing a CrystalDecisions CrystalreportViewer which I plan to use to display all my reports. In my report generating form I have DataGridView named "PersonnelDataGridView" which is being populated correctly. I have designed the report named "RptPersonnel.rpt" with headers and other details as required. But I am unable to link the DataGridView with the report as a result when I show the report only the header is getting displayed. How do I link the DataGridView with the CystalReport in code??

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Link DataGridView to CrystalDecisions Report

    I don't use Crystal Reports but I'd be very surprised if you couldn't use a DataSet/DataTable as the source. Assuming you can, just bind the same DataSet/DataTable to your DataGridView. If you use the same source for both then they will obviously display the same data.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    53

    Re: Link DataGridView to CrystalDecisions Report

    There is a TableAdapter named "PersonnelTableAdapter" which is bound to the DataGridView. But how do I link to the Crystal Report in code??

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Link DataGridView to CrystalDecisions Report

    Quote Originally Posted by Eager_Beever View Post
    There is a TableAdapter named "PersonnelTableAdapter" which is bound to the DataGridView.
    No there isn't. Table adapters don't contain data. They open connections to a database to retrieve or save data. That data is stored in a DataTable that is itself in a DataSet and that's what's bound to the grid.
    Quote Originally Posted by Eager_Beever View Post
    But how do I link to the Crystal Report in code??
    I don't know because, as I said, I don't use CR but if I wanted to know then I'd do the bleeding obvious and search the web for datatable crystal reports or the like.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,508

    Re: Link DataGridView to CrystalDecisions Report

    Here's an example of using a dataset as a datasource for CR,
    Code:
            Dim ds As New WaterTablesDataSet
            Dim taG As New WaterTablesDataSetTableAdapters.groupsTableAdapter
            Dim taL As New WaterTablesDataSetTableAdapters.lotsTableAdapter
            Dim taU As New WaterTablesDataSetTableAdapters.usersTableAdapter
            taG.FillByNoDoubles(ds.groups)
            taL.FillByNoDoubles(ds.lots)
            taU.Fill(ds.users)
            Dim rpt As New rptLateralAcreageReport
            rpt.SetDataSource(ds)
            rpt.SummaryInfo.ReportAuthor = clsCoInfo.CompName
            rpt.SummaryInfo.ReportTitle = "Lateral Acreage Report"
            Dim frm As New frmReports
            frm.CrystalReportViewer1.ReportSource = rpt
            frm.Show()
    The CR datasource can also be set to a single datatable. This example uses the dataset because the report was designed using two tables.

Tags for this Thread

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