I am using a dynamic table in a dataset and filling it with data from various other tables, based on a linq query. I have created a report.rdlc, based on that table and put it in a reportviewer on the form.
For information, I have used several reports in the ReportViewer control to show pre-filled tables using the TableAdapter.Fill method with success. I only have this problem when I'm using a dynamic table that I fill programmatically.
I have spent an unbelievable amount of hours researching ReportViewer control, Binding Datasets to ReportViewers dynamically, creating datasets, etc.
I have also used the smart tag to choose the proper DataSet and Rebind it, and I still can't get anything to display.
The following is the condensed code which works in a datagridview and also works using Crystal Reports, which I'm trying to get away from:
Dim ds As New TalkScheduleDataSet
Dim dt As DataTable = ds.ScheduleReport
Dim sched = From s In db.TalkSchedules Where s.Date >= CDate(fromDate) And s.Date <= CDate(toDate) Select s
For Each sch In sched
dt.Rows.Add(sch.xxxx
dt.AcceptChange
Next
dgvReport.DataSource = dt
dgvReport.Refresh()
ReportViewer.Refresh()
end sub
The data shows in the Datagridview, but the report always shows empty.
I have tried the following:
ReportViewer.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("TalkScheduleDataSet", dt))
ReportViewer.Update()
ReportViewer.Refresh()
I've tried in various combinations below code:
With ReportViewer
.ReportPath
.Reset()
.LocalReport.DataSources.Add(WinForms.ReportDataSource("DataSetName", dt)
.Refresh()
End With
Also tried the following after filling the table, which still also shows in DataGrid:
Dim rds ReportDataSource = new ReportDataSource("TalkScheduleDataSet", dt)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(rds)
ReportViewer1.LocalReport.Refresh();
None of the above shows anything on the reportViewer, and there are no errors.
I've even tried setting up the Table and DataSet using a class, and then referencing it with the ReportViewer.
The ReportViewer works when I use a pre-filled table in a dataset, but I'm confined to only the data from that dataset. I use the dynamic dataset to add data from several tables into one table and display it in the report.
Hope this is clear enough. I know some will think, If it works with CR then why not use CR. The fact is though, I can't get it to work using a ReportViewer, and I don't know why.