I'm using Wpf to View Some reports using Report Viewer .. I designed the a report using sql report builder 'ReportByTopic.rdl' added it to the solution .. the DataSet inside the rdl file named 'Dataset1' and there are three parameters @TopicId ,@SDate, @EDate tested the query and it's working fine
I am trying to load filterd data into ReportViewer but no data is viewed
and here's the code
private void reportViewer_load()
{
ReportParameter[] Params = new ReportParameters[3];
Params[0] = new ReportParameter("TopicId", "4");
Params[1] = new ReportParameter("SDate", "2009-01-01");
Params[2] = new ReportParameter("EDate", "2017-01-01");
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
reportViewer.LocalReport.ReportPath = "Reports\ReportByTopic.rdl";
reportViewer.LocalReport.DataSource.Add(rds)
reportViewer.LocalReport.SetParameters(Params);
reportViewer.Refresh();
}
so where did I go wrong
UPDATE
Based on the answers I made some changes to the above code. First I used a method 'GetData' which returns a datatable of all the data I need using the same query I used to design the rdl file . The edited code
private void reportViewer_load()
{
ReportParameter[] Params = new ReportParameters[3];
Params[0] = new ReportParameter("TopicId", "4");
Params[1] = new ReportParameter("SDate", "2009-01-01");
Params[2] = new ReportParameter("EDate", "2017-01-01");
ReportDataSource rds = new ReportDataSource("DataSet1", GetData());
reportViewer.LocalReport.ReportPath = "Reports\ReportByTopic.rdl";
reportViewer.LocalReport.DataSource.Add(rds)
reportViewer.LocalReport.SetParameters(Params);
reportViewer.Refresh();
}
the datatable gets filled correctly with 900 rows, but still the reportViewer doesn't