A First Look at the VS2008 ReportViewer
Now that Visual Studio 2008 has shipped, you finally can get a firm grip on what's there (and what's still missing). One of my favorite features of Visual Studio 2005 is the ReportViewer control that leverages the considerable work done by Microsoft to develop and refine the Report Definition Language (RDL) first seen in SQL Server Reporting Services. For Visual Studio 2008, this control has been improved to provide compressed PDF output (which can make report deployment faster) and expanded local print functionality. The design-time experience also has been tweaked. There are two new project templates. One creates a blank report that's already bound to the Report Viewer control and the Report Wizard as I discuss in more detail in this article. You'll also find the Expression Editor has been tuned to provide common sample expressions.
The Report Wizard
When you start Visual Studio 2008, you'll notice a pleasant surprise—a Reporting project type and a Reports Application template (in addition to the Crystal Reports Application template)—as shown in Figure 1. Using this project template, you would expect to get a quick start on a new report that leverages the ReportViewer control. Unfortunately, as we'll see later, this wizard leaves something to be desired.
The Business Intelligence Project type does not appear in the Visual Studio 2008 menus. The plan is to re-introduce these when SQL Server 2008 ships later next year. Until then, the only way to interactively create Reporting Services reports is to use the Business Intelligence tools in Visual Studio 2005.
Creating a New Reports Application
Choosing the Reports Application template launches the Report Wizard that should be familiar to those who have run the SQL Server Reporting Services Report Wizard. Generally intuitive, it's designed to mimic the steps developers should take when building a locally-hosted RDLc-based report.
Figure 1: Creating a Report Project using the RDL template.
That is, the wizard walks you through the following steps:
- Select (or create) a Data Source to retrieve data for the report.
- Choose the report type—such as Tabular or Matrix.
- Choose the columns to be included in the report, those used to determine the page and group breaks and the detail columns.
- Define the report layout and formatting.
The end result is a new RDLC file that defines the report as well as a strongly typed TableAdapter that contains the DataSets used to populate the report controls.
Running the Wizard
The first step that creates a new Data Source has not changed from Visual Studio 2005—the wizard simply creates a standard strongly typed Dataset over an entire table and presents the developer with the following (new) dialog as shown in Figure 2. To continue, your only choice is to select one of the DataSets built by the Data Source configuration wizard. No, you aren't given an opportunity to launch the Query Builder dialog—ever.
Figure 2: Choosing a DataSet table.
I'm not at all thrilled with this approach. First, it's rare that a report would be built against an entire table. More realistically, it would be built against a focused rowset returned by the product of a JOIN or at least a parameterized SELECT statement. As it is, there is no opportunity to build a JOIN query or even provide a filtering parameter to focus the rowset on a subset of the table rows—not too clever. A better approach might be to write a special stored procedure that returns the correctly JOINed query product for your report—unfortunately, this approach is crippled as well as I explain later.
The next few dialogs are drawn directly from the 2005 Business Intelligence (BI) addin for Reporting Services. They give you an opportunity to choose the columns to include in the report, and those that determine where to break the pages and groups. Subsequent dialogs help define whether the report should be "stepped" or in "block" mode, whether or not it should include subtotals and drilldown, and the basic color layout—again, these are drawn right out of the SQL Server 2005 Reporting Services Report Wizard.