Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameters to SSRS report programmatically

I'm looking for a little help on programmatically passing parameters to a SSRS report via VB.NET and ASP.NET. This seems like it should be a relatively simple thing to do, but I haven't had much luck finding help on this.

Does anyone have any suggestions on where to go to get help with this, or perhaps even some sample code?

Thanks.

like image 550
LunaCrescens Avatar asked Dec 15 '08 15:12

LunaCrescens


2 Answers

You can do the following,: (it works both on local reports as in Full Blown SSRS reports. but in full mode, use the appropriate class, the parameter part remains the same)

LocalReport myReport = new LocalReport();
myReport.ReportPath = Server.MapPath("~/Path/To/Report.rdlc");

ReportParameter myParam = new ReportParameter("ParamName", "ParamValue");
myReport.SetParameters(new ReportParameter[] { myParam });

// more code here to render report
like image 116
Abram Simon Avatar answered Sep 19 '22 16:09

Abram Simon


If the Report server is directly accessible, you can pass parameters in the Querystring if you are accessing the repoort with a URL:

http://MyServer/ReportServer/?MyReport&rs:Command=Render&Param1=54321&Param2=product

You can add output formatting by adding the following on the end of the URL:

&rs:Format=Excel

or

&rs:Format=PDF

like image 30
HectorMac Avatar answered Sep 20 '22 16:09

HectorMac