Click here to Skip to main content
15,559,819 members
Articles / Web Development / ASP.NET
Posted 29 Oct 2013

Tagged as


42 bookmarked

Call SSRS Reports by using C#

Rate me:
Please Sign up or sign in to vote.
4.60/5 (12 votes)
29 Oct 2013CPOL2 min read
Call/Run SSRS Reports by using C#


Sometimes user are creating SSRS Reports and want to Run that SSRS Report by using their Web Appliation. Here I am describing how to Call a SSRS Report by using C#.

I am here assuming that User know how to create SSRS Report. So here I am only describing to Call SSRS Report by using C#.


What is the need to call SSRS Report using C#?

SSRS also provides a 'Report Builder' tool for less technical IT workers to format SQL reports of lesser complexity. After Creating of SSRS Reports for the business need, most of the user want to view it on Website or WebApplication by using different languages.

Using the code

Steps Used for Call SSRS Report are : -

  • Create a ReportPage.aspx page having ReportViewer Control, named : - rptViewer
  • In ReportPage.aspx.cs, Add Reference of Microsoft.Reporting.WebForms
  • It will be easily found into the location: - c:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer\Microsoft.ReportViewer.WebForms.dll
  • Set the Processing Mode to Remote
  • Pass the Report URL and Report Path
  • If you pass the Parameter then Pass that Parameter
  • If User want to pass Credential of Report Server, then by using ReportServerCredentials Credential will be passed
  • Call the SSRS Report

Code to Call SSRS Report

private void ShowReport()
        string urlReportServer = "http://sqlDBServer//Reportserver";
        rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local
        rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer); //Set the ReportServer Url
        rptViewer.ServerReport.ReportPath = "/ReportName"; //Passing the Report Path                

        //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report
        ArrayList reportParam = new ArrayList();
        reportParam = ReportDefaultPatam();

        ReportParameter[] param = new ReportParameter[reportParam.Count];
        for (int k = 0; k < reportParam.Count; k++)
            param[k] = (ReportParameter)reportParam[k];
        // pass crendentitilas
        //rptViewer.ServerReport.ReportServerCredentials = 
        //  new ReportServerCredentials("uName", "PassWORD", "doMain");

        //pass parmeters to report
        rptViewer.ServerReport.SetParameters(param); //Set Report Parameters
    catch (Exception ex)
        throw ex;

On the above function ReportDefaultPatam function is used to Set the Default Parameters for the SSRS Report.

reportParam = ReportDefaultPatam();

We are fetching the Report Parameters into ArrayList.

For every parameter of ArrayList, we are adding them into ReportParameter array.

Collection of ReportParameter array is set into the Report by using the below code : -


In the ReportDefaultPatam function, we are adding SSRS Report Parameters into the Array List

private ArrayList ReportDefaultPatam()
    ArrayList arrLstDefaultParam = new ArrayList();
    arrLstDefaultParam.Add(CreateReportParameter("ReportTitle", "Title of Report"));
    arrLstDefaultParam.Add(CreateReportParameter("ReportSubTitle", "Sub Title of Report"));
    return arrLstDefaultParam;

On the above function we are using CreateReportParameter function. In this function we are returning the ReportParameter type having the information of Parameter Name and Parameter Value.

 private ReportParameter CreateReportParameter(string paramName, string pramValue)
    ReportParameter aParam = new ReportParameter(paramName, pramValue);
    return aParam;

Points of Interest

I was trying to Call the SSRS Report by using C#. For that, I had found the simplest ways, Which I described here. I had also Called the SSIS Package by using C# and SQL Server. Which I described into my another article. These articles are:


  • 29th October, 2013: Initial post.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior) R1 RCM Pvt. Ltd.
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

GeneralRegarding Item path Pin
Member 149302722-Mar-21 3:06
Member 149302722-Mar-21 3:06 
QuestionWhere to call ShowReport() ? Pin
Divyapalivela11-Jun-19 0:14
Divyapalivela11-Jun-19 0:14 
AnswerRe: Where to call ShowReport() ? Pin
Sandeep Kumar Tripathi6-Aug-19 2:36
Sandeep Kumar Tripathi6-Aug-19 2:36 
QuestionConfiguration of SSRS Pin
christine sarsonas17-Dec-14 20:50
christine sarsonas17-Dec-14 20:50 
Question"The request failed with HTTP status 401: Unauthorized." You can Heal me ? Pin
Member 108076119-May-14 12:01
Member 108076119-May-14 12:01 
QuestionProblem with SSRS Authentica​tion - don't want to use Custom Authentica​tion - Please guide Pin
Member 1069685125-Mar-14 5:20
Member 1069685125-Mar-14 5:20 
QuestionHow to make SSRS report to accept parameters from C# Pin
Member 1067755917-Mar-14 12:57
Member 1067755917-Mar-14 12:57 
QuestionHow to download this sample code Pin
Member 191357527-Nov-13 18:28
Member 191357527-Nov-13 18:28 
SuggestionArrayList Pin
Richard Deeming8-Nov-13 9:02
mveRichard Deeming8-Nov-13 9:02 
GeneralGood Article Pin
Gehan Fernando3-Nov-13 23:18
Gehan Fernando3-Nov-13 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.