Monday 23 September 2013

SSRS Report and Report builder integration in ASP.NET Web Page

1)Open VS 2010 and Create a ASP.NET Web Application project.

 
2)Add a ScriptManager (AJAX Externsions), ReportViewer (Reporting) and Button (Standard) control from the toolbox in the Default.aspx page.

3)Double Click on the button, to add the following code in the button event.
protected void Button1_Click(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/Report Project2/Report4";
ReportViewer1.ServerReport.Refresh();

// Below code demonstrate the Parameter passing method. User only if you have parameters into the reports.
Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection = new Microsoft.Reporting.WebForms.ReportParameter[1];
reportParameterCollection[0] = new Microsoft.Reporting.WebForms.ReportParameter();
reportParameterCollection[0].Name = Perks.Constants.Pages.ClientAdmin.ShowInvoice.QueryStrings.INVOICEID;
reportParameterCollection[0].Values.Add(Request.QueryString[Perks.Constants.Pages.ClientAdmin.ShowInvoice.QueryStrings.INVOICEID].ToString());
ReportViewer1.ServerReport.SetParameters(reportParameterCollection);

ReportViewer1.ServerReport.Refresh();


}




 
Following code will return list of all reports deployed on report server.

dynamic clientCredentials = new NetworkCredential("user", "password", "domain");
ReportingService2010.ReportingService2010SoapClient client = new ReportingService2010.ReportingService2010SoapClient();
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential = clientCredentials;
client.Open();
TrustedUserHeader t = new TrustedUserHeader();
CatalogItem[] items = null;
ServerInfoHeader oServerInfoHeader = client.ListChildren(t, "/", true, items);
foreach (CatalogItem item in items) {
    ListBox1.Items.Add(item.Name);
}

Open a report in Report Builder from URL

As per this MDN link, we can start report builder by typing URL in browser. Suppose, we can open Report Builder 1.0 from URL by following URL
http://localhost:8080/ReportServer/reportbuilder/reportbuilder.application
This way we can also open Report Builder 2.0 or Report builder 3.0. Following URL opens Report Builder 2.0
http://localhost:8080/ReportServer/reportbuilder/reportbuilder_2_0_0_0.application
If we have configured SSRS in SharePoint integration mode then as per above mentioned MSDN link, we get an option to start Report Builder with a report or model pre-loaded.
In one of the projects, we need the same kind of functionality in SSRS configured without SharePoint integration mode. So, after searching, I found something interesting in this link. As per this, we can open the report by passing the report name after report builder URL.
I have created a test report (“TestFromURL.rdl”) to test this and deployed this into root directory on Report Server. By clicking following URL, report successfully opened in Report Builder 2.0.
http://localhost:8080/ReportServer/reportbuilder/reportbuilder_2_0_0_0.application?http://localhost:8080/reportserver/testfromUrl
As the same way, we can also open report from any path inside report server.

source http://beyondrelational.com/modules/2/blogs/115/posts/11145/open-a-report-in-report-builder-from-url.aspx














6 comments:

  1. If you have parameters on reports then pass parameter's value in anyway.
    For just make it simple, values can be passed as below.
    reportParameterCollection[0].Name ="value";

    ReplyDelete
  2. question regarding the security of this approach.

    When you open Report builder from your ASP page, when trying to save report back to reporting services what user will it use ?

    For example, if i have ASP page impersonating a specific windows user , which is only account allowed to access reporting services.
    Will this still be case if report builder opens ? or at least for process of resubmitting a report to reporting services , and the viewing of created Data Models ?

    and is there a way to make report builder run under the same windows user my ASP page is impersonating .

    Thank you for any help.

    ReplyDelete
  3. Do you know what security report builder will use ?

    For example, if i have my asp page impersonating a windows user, and only that user has rights on reporting services, if i launch report builder like suggested, will report builder run under the impersonated account, or use the accessing users windows credentials who doesn't have access rights to reporting services ?

    ReplyDelete
  4. Hi Rahman.. please refer below urls..

    http://technet.microsoft.com/en-us/library/ff519564.aspx

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/379f865f-e452-441a-a389-41cdca68fd44/reportbuilder-20-not-asking-for-credentials-when-previewing-a-server-report?forum=sqlreportingservices

    ReplyDelete
  5. Hi,

    How do I do Ad-hoc reporting in SSRS 2012. And how is it use full to the end user. Basically I wanted to know the roll of developer and business Users. Could you please demonstrate with an example from scratch to and end user perspective.

    ReplyDelete
    Replies
    1. HI Katagei,
      Following url can help you.Please feel free to wight us anymore.
      http://msbitips.blogspot.in/2014/01/report-builder-30-creating-basic-report.html
      http://beyondrelational.com/modules/2/blogs/39/posts/17467/how-to-create-ad-hoc-report-using-ssrs-and-ssas-cube.aspx

      Delete

Azure AzCopy Command in Action

Azure AzCopy Command  in Action -  Install - Module - Name Az - Scope CurrentUser - Repository PSGallery - Force # This simple PowerShell ...