Capturing a sql paramter and display it in the report

Go To


I have a report that displays data based on date range: start date, and end date. These are the parameters fed to the dataset. Is there a way to intercept these parameters and feed them to the report?

Here is my code:

ReportDataSource rds2 = new ReportDataSource("DataSet1", ods); 
ods.SelectMethod = "GetTransactionByDateRange"; 
ods.TypeName = "ConsumablesTransactionLogBLL"; 

ods.SelectParameters.Add("sd", System.TypeCode.String, dateRange[0]); 
ods.SelectParameters.Add("ed", System.TypeCode.String, dateRange[1]); 
reportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/Consumables_By_Range.rdlc");

Thank you,


2012-04-03 19:53
by Risho


Create your parameters and bind them to the report

  Microsoft.Reporting.WebForms.ReportParameter sd = new Microsoft.Reporting.WebForms.ReportParameter("sd",dateRange[0]);
  Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("ed",dateRange[1]);

  reportViewer1.LocalReport.SetParameters(new ReportParameter[] { sd, ed}});

In the RDLC you need to set up the parameters in the ReportData window to match the names.

2012-04-03 20:53
by Dave D