Capturing a sql paramter and display it in the asp.net report

Go To StackoverFlow.com

0

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:

reportViewer1.LocalReport.DataSources.Clear(); 
ReportDataSource rds2 = new ReportDataSource("DataSet1", ods); 
reportViewer1.LocalReport.DataSources.Add(rds2); 
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,

Risho

2012-04-03 19:53
by Risho


0

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
Ads