Patrice Calve

Life's short, have fun
posts - 51, comments - 49, trackbacks - 31

My Links

News

Archives

Post Categories

Image Galleries

Friday, March 13, 2009

How to display a Reporting Services Report in a Winform application

Step 1: prepare yourself :)

The first step to show a report on a windows application is to figure out the url and path of the report!

Sql Reporting Services has 2 virtual directories:

  • /Reports: renders the reports to the user in a user-friendly web page
  • /ReportServer: executes the report

When your boss asks you to display a report in a winform application, he(she) will likely send you a url in the following forms:

The urls above don't translate to properties that you need in a winform (or webform)...

To "consume" a report from a winform, you can't use the url above, you need another url.  Actually, you need two things:

  1. The Report Server Url
  2. The Path of the report

In the following two(2) steps, we'll see how to figure out how to discover that information.

Step 2: The Report Server Url

Ask your administrator, or find it for yourself!  The Reporting Server url is hidden in the report!

  • Open the report in a browser (ie)
  • Right click on the report's header (ex: on the report's title) -> View Source
  • Locate the meta tag "Report Server", the "Content" attribute will contain the Report Server value: ex
    • <META Name="Report Server" CONTENT="HTTP://ReportingServices/reportserver">

{ReportServerUrl} = "HTTP://ReportingServices/reportserver"

Step 3: The Report Path

The Report Path is something you have to "build" manually.

  • Open the ServerUrl in the browser (ie), a page with a list of folders will be shown
  • Copy the text of the folder into notepad or something like that. (referred bellow as {MyFolder})
  • Navigate to the folder, a page with a list of reports will be shown
  • Copy the text of the report into notepad: (referred bellow as {MyReportName})

The ReportPath will be the following: /{MyFolder}/{MyReportName}

ex: {ReportPath} = "/TMF Reports/TMF1200 - Project Status"

 

Step 4: The ReportViewer in the Winform

Now, you're ready to add the report on the winform.

  • Open the winform in Visual Studio
  • Add a ReportViewer on the designer (Toolbox > Data > ReportViewer)
  • Set the following properties:

Run the application.

Pat

Note To Microsoft

It would nice if it was easier to discover reports from within Visual Studio.  A wizard where a dev could enter any of the following:

Thanks, Pat

posted @ Friday, March 13, 2009 2:21 PM | Feedback (1) |

Powered by: