Having trouble binding a ReportViewer to a DataSet
Posted on 2007-07-31
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:
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.