0
Reply

Steps to generate Sql server reporting services.

Sanjeev rajput

Sanjeev rajput

Jan 30 2013 1:04 AM
1.2k

Prerequisites: Configured Report Server

Note: To check the configuration of the report server type the URL

http://<Server IP>/Reports

 

Steps to create a SQL Report:

1.       Create a New project in VS of 'Report Server project Wizard' in 'SQL Server Bussiness Development Studio' Template.

2.       Set the Database credentials and define the connection string.

3.       Set SQL Query or set the SP name and its Parameters.

4.       Set the Report Type(Tabular or Matrix)

5.       Select the Report Fields.

6.       Choose the deployment location and set the deployment folder .

7.       Provide the Report Name and Finish.

8.       Set the properties of Project by right clicking on the project in Sol. Explorer and set the TargetDatasourceFolder='WhateverYouWant', TargetReportFolder='WhateverYouWant' and TargetServerURL='http://<Server IP>/ReportServer

9.       Build the project and deploy it on the Report  Server by Right Clicking on the project and clicking on Deploy.

 

Steps to Integrate the Report with web application:

1.       Create a new Web application.

2.       Add a button on the Page.

3.       Add the Microsoft Report  Viewer Control on the Page.

On the Code file of the project add the assembly reference: Microsoft.Reporting.WebForms

 

4.       Add the buton click handler and add the given below code:

ReportParameter[] parm = new ReportParameter[2];

 

            parm[0] = new ReportParameter("ParameterName", "ParameterValue");

parm[1] = new ReportParameter("ParameterName", "ParameterValue");

 

            ReportViewer1.ShowCredentialPrompts = false;

 

            ReportViewer1.ServerReport.ReportServerCredentials = new ReportCredentials("UserName", "Password", "HostName");

 

            ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

 

            ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://<Report Server IP>/ReportServer");

 

            ReportViewer1.ServerReport.ReportPath = "/<ReportFolder>/<ReportName>";

 

            ReportViewer1.ServerReport.SetParameters(parm);

 

            ReportViewer1.ServerReport.Refresh();

 

5.  Add the Given Below Class in the Project.

 

public class ReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials

    {

 

        string _userName, _password, _domain;

 

        public ReportCredentials(string userName, string password, string domain)

        {

 

            _userName = userName;

 

            _password = password;

 

            _domain = domain;

 

        }

 

        public System.Security.Principal.WindowsIdentity ImpersonationUser

        {

 

            get

            {

 

                return null;

 

            }

 

        }

 

 

 

        public System.Net.ICredentials NetworkCredentials

        {

 

            get

            {

 

                return new System.Net.NetworkCredential(_userName, _password, _domain);

 

            }

 

        }

 

 

 

        public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)

        {

 

            userName = _userName;

 

            password = _password;

 

            authority = _domain;

 

            authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");

 

            return true;

 

        }

 

    }

}

 

6.       Now Build the Application the Run the same page and click on the button.