Call SSRS Report With Prameters from ASP.NET Web Application

Call SSRS Report With Prameters from ASP.NET Web Application

1. First of all open Visual Studio 2008 then go to New >> Website

Call SSRS Report With Parameters From ASP.NET-1

2. Then Browse the directory where you want to save New Web Site.

Call SSRS Report With Parameters From ASP.NET-2

3. Now in your web page add following controls:

  • One ScriptManager
  • One Button
  • One MicrosoftReportViewer

So your web page design will look like following:Call SSRS Report With Parameters From ASP.NET-3

4. Now add following code on button’s click event in your .cs file :

using Microsoft.Reporting.WebForms;

try
{
   MyReportViewer.ProcessingMode = ProcessingMode.Remote;
   MyReportViewer.ServerReport.ReportServerUrl = new Uri("http://bhushan-pc:8080/ReportServer");
   MyReportViewer.ServerReport.ReportPath = "/StartSSRS/PersonAddressDetails";
   MyReportViewer.ServerReport.Refresh();

   ReportParameter[] reportParameterCollection = new ReportParameter[1];       //Array size describes the number of paramaters.
   reportParameterCollection[0] = new ReportParameter();
   reportParameterCollection[0].Name = "City";                                 //Give Your Parameter Name
   reportParameterCollection[0].Values.Add("Seattle");                         //Pass Parametrs's value here.
   MyReportViewer.ServerReport.SetParameters(reportParameterCollection);
   MyReportViewer.ServerReport.Refresh();
}
catch (Exception ex)
{
   Response.Write(ex.ToString());
}

Call SSRS Report With Parameters From ASP.NET-4

5. Now Run your website and click on Get Report Button.
It will show following results in your web page :
Call SSRS Report With Parameters From ASP.NET-5

Congratulations! We successfully called our Parameterized SSRS report from ASP.NET web application.

3 thoughts on “Call SSRS Report With Prameters from ASP.NET Web Application

  1. Hi BHUSHAN SHAH,
    I got a doubt here. The major drawback of SSRS is it can’t be hosted on public url,only withing the Report Server machine only the URL works.Tha’s why people are going for asp.net Web hosting or publishing it in SharePoint portal to make SSRS Report publicly accessible to the end user.
    What you shown above is the SSRS Server hosting(A report already deployed onto your Report server is being called from your .net website) Can you pls tell me,if we deploy this website will the report page will be accessible from any public url ??

Leave a Reply to Shovan Mukherjee Cancel reply

Your email address will not be published. Required fields are marked *