September 19, 2024
ssrs crystal report

Call SSRS Report in ASP.NET Project

We know SQL Server Reporting Services or SSRS is a server based reporting system. Like other reporting system (Crystal Report or rdlc) we do not need to design UI. It has built in mechanism to automatically generate some input related UI like Calendar, DropDownList, Input TextBox etc based on reports parameter. We can easily call a SSRS report through web browser.

But we can also call them from our ASP.NET project. This article describes how to add a SSRS report in ASP.NET project? or how to integrate a SSRS report in ASP.NET project? Summary of the articles:

  • Design SSRS Report
  • Call SSRS Report without Parameter
  • Call SSRS Report with Parameter

Design SSRS Report

Step 1
Design your SSRS report by using report designing tools. You can use Visual Studio or ReportBuilder.

Step 2
Include a Report Viewer in  .aspx page.

Step 3
Include a ScriptManager in that page [if required].

Step 4
Include a button.

Call SSRS Report without Parameter
Write the following code under button click event. Run the project project. If every thing is fine report will be displayed.

ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.10.15/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/ReportName";
ReportViewer1.ServerReport.Refresh();

NB: http://192.168.10.15/ReportServer is the Report Server URL

Call SSRS Report with Parameter
Write the following code under button click event. Run the project. If every thing is fine  report will be displayed.

Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[1];
Param[0] = new Microsoft.Reporting.WebForms.ReportParameter("ReportParameter1", "UK");
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.10.15/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/ReportName";
ReportViewer1.ServerReport.SetParameters(Param);
ReportViewer1.ServerReport.Refresh();

//NB: http://192.168.10.15/ReportServer is the Report Server URL
ReportParameter1 is a string type parameter added in SSRS report.

In this way we can add a SSRS report in asp.net C# project.

Rashedul Alam

I am a software engineer/architect, technology enthusiast, technology coach, blogger, travel photographer. I like to share my knowledge and technical stuff with others.

View all posts by Rashedul Alam →

3 thoughts on “Call SSRS Report in ASP.NET Project

Leave a Reply

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