Having trouble binding a ReportViewer to a DataSet

I am having trouble binding a ReportViewer to a previously defined Dataset.  Per solutions I have read on EE I have done the following:

1) The user selects various criteria from combo boxes & DateTimePickers and I create a dynamic SQL statement and fill a DataAdapter with a Dataset & Table as shown:
da.Fill(DS, "MyTable")

2) I have bound a Dataset to a DataGridView with the code:
dgvCoa.DataSource = DS.Tables("MyTable")

3) Stealing shamelessly from EE I created a "blank" dataset using the Add Datasource wizard, then I created a blank table and added columns to exactly match the schema of DS.Tables("MyTable")

4) I created a Report by dragging fields from the dataset in step 3

5) I created a "Print" button and added the following lines of code:
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("dsCOA", Me.DS.Tables("MyTable")))

Where "dsCOA" is the blank dataset I created with the add datasource wizard

My report loads, but no data is present (only headers from the blank dataset).

I am going to need to create many reports with this method (or something similar) and I would be grateful for any assistance.

Thanks !!
Who is Participating?
Not sure about the Report Viewer...

But why don't you try out a Crystal Report?  

First, add a Strongly-Typed DataSet to your project:
    Project Menu | Add new Item...
    Select DataSet, and name it "MyDataSet"
    Once it opens, right-click on the designer, and select Add | DataTable
    Click on the table name and rename it "MyTable"
    Right-click on the table and select Add | Column to add as many columns as you need.
    Save your dataset

Once you have added a DataSet to your
project, then all you have to do is the following:

1.  Add a CrystalReport to your project:  
        Project menu | Add New Item...
        Select CrystalReport, name it "rptCoa"
        Use the Report Wizard to create a Standard report.
        Expand the Project Data tree node, then ADO.NET DataSets, then the DataSet you added to your
            project.  Select it by moving it to the right.
        Select the entire table, or desired fields to display.
        Click finish.
        Save and Build your project.

2.  Add a form to your project, and name it "frmViewer".
         Add a CrystalReportViewer to the form.

3.  On the frmViewer_Load event, add the following code to view your report:
        Dim ds As New MyDataSet()
        'Load your dataset (ds)

        'Create a new instance of the report
        Dim rpt As New rptCoa()

        'Set the report datasource to your loaded dataset

        'Set the report for the Viewer
        Me.CrystalReportViewer1.ReportSource = rpt

That's it.  When you load your form, your report will be displayed in the viewer:

        Dim frm As New frmViewer()

SteveB2175Author Commented:
As an update, I added the following lines:

 Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "WindowsApplication1.rptCoa.rdlc"

Ahead of

Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("dsCOA", Me.DS.Tables("MyTable")))

Now I get the following message when I run the report:

A datasource instance has not been supplied for data source 'dsCOA_MyTable'
SteveB2175Author Commented:
I'm running Visual Studio 2005 Standard Edition, and Crystal Reports does not appear on the Add New Item dialog.

Do I need to do something special to make CR available, or does it require an upgrade to a higher version of Visual Studio ?

I would happily implement your solution if CR were available.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

SteveB2175Author Commented:
I've researched this, and it appears that VS standard edition does not include Crystal reports.
Oh, bummers.  Sorry.
SteveB2175Author Commented:
So, if I were to upgrade Visual Studio, does CR seamlessly integrate into my project and distribute with new publications as the Reportviewer does ?
SteveB2175Author Commented:
OK VBRocks, I got approval to purchase VS Pro !!

Thanks for your help.
Oh, your going to love it!  VS Pro Rocks!

Just 1 note, when you create a project that uses Crystal Reports, and then get ready to deploy it,
Create a Setup Project for the program, and then add the Crystal Reports Merge Module for VS 2005.
And then run the setup program on every computer that will use your program.  The installer will
install Crystal's merge modules for you.

It's a cynch to add them to the installer, just do the following:
    Right-Click on the Setup Project,
    Click Properties
    Click the Pre-Requisites button.
    Check Crystal Reports for .NET Framework 2.0.
    Click OK, then OK again to close the properties window.

You should be good to go.
SteveB2175Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.