Scott G

Scott G

  • NA
  • 103
  • 7.1k

Pass variable to SSRS report as parameter

Nov 24 2020 12:33 PM

I have 2 winforms The first has a button that opens the second with a reportviewer that opens an SSRS report with a single parameter (CaseNo). I want to be able to pass the CaseNo from C# to the SSRS report.

This is what I currently have but I am not sure how to modify it to pass the parameter to the report.
  1. private void btnOpenSummary_Click(object sender, EventArgs e)  
  2. {  
  3.     CaseSummRpt summRpt = new CaseSummRpt("Case_Summary"" / Security", lblCaseNo.Text);  
  4.     summRpt.ShowDialog();
  5. }  
Report Viewer Form
  1. public CaseSummRpt(string rptText, string rptFolder, string CaseNo)  
  2. {  
  3.     InitializeComponent();  
  4.     string rptName;  
  5.     rptName = rptFolder + "/" + rptText;  
  6.     reportViewer1.ServerReport.ReportServerUrl = new Uri("http://servername:8000/servername_server");
  7.     reportViewer1.ServerReport.ReportPath = rptName;
  8. }

Answers (2)