CHAPTER 9 RENDERING REPORTS FROM .NET APPLICATIONS
Note The Report Viewer controls are included with current versions of SQL Server and Visual Studio. You can
also download the redistributable package for machines that will be running the application and that do not have
Visual Studio/SQL Server installed.
While the Report Viewer controls are the method that most Visual Studio users will probably employ
to render reports, the most universally usable rendering method is via URL access. In this case, SSRS
2012 provides some defaults for most reporting options. For example, SSRS provides a default user
interface for entering parameter and filter information. It prompts you for login information if
necessary, and it defaults to rendering in HTML format. You get all this simply by passing the URL of the
report from the browser. This is most useful if you’re rendering your reports using just your Web
browser, with no other controlling application.
You can optionally pass parameters along with the URL to change these default behaviors, provide
login information, change the rendering format, hide the parameter toolbar, and much more. This is
useful if you have a custom application and want to control these options yourself, rather than provide
the default user interface.
You can perform many of the same actions using the Report Server Web service, but there are no
real defaults and the actual display of the returned data to the user is left up to the application developer.
By using the Web browser in an ASP.NET application, or embedded in a Windows Forms application,
you get the benefits of the URL rendering method, but you can exercise control over it. This provides
users with a more integrated experience. The methods covered in this chapter apply largely to both
Windows Forms and Web Forms applications. For one of the projects, we’ll show how to build a
Windows Forms-based report viewer that allows you to use SSRS 2012 as the reporting solution for your
application.
In this chapter, you’ll do the following:
URL rendering access: Learn how to build a URL through which a client
application can access a report on the report server. You’ll use the Employee
Service Cost report in the example (available with the code download for this
chapter in the Source Code/Download section of the Apress Web site at
http://www.apress.com).
URL reporting parameters: Explore the reporting parameters that, when
specified in the URL, control how the report is rendered. You can specify the
actual format (for example, HTML or PDF). You can specify that a specific page
in a report be rendered, or you can search for a particular word and start
rendering on that page.
URL viewer application: Build a simple .NET Windows Forms application that
accesses and renders a report via a WebBrowser control that you’ll embed in a
form.
Report Server Web service calls: Use calls to the Report Server Web service to
query for the report criteria and filter parameters. This allows you to display
these on your Windows Forms application. You’ll then use the SOAP API again
to see whether the parameters have a list of values from which the user can
select. If so, you’ll use those values to populate combo boxes for each
parameter. You’ll also give the user a combo box to select a rendering format.
You’ll then display all the selections to the users and use their selected values to