Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Click here to receive your FREE subscription to Visual Studio Magazine

email article
printer friendly
get the code
more resources

Build Client-Side Reports Easily
VS 2005's new ReportViewer control and its built-in Report Designer enable smart-client and Web page designers to lay out, format, embed, export, and print interactive reports without running a SQL Server Report Server.
by Roger Jennings

November 18, 2005

Technology Toolbox: Visual Basic; C#; SQL Server; ASP.NET; XML; SQL Server 2000, MSDE, 2005, or Express; Visual Studio 2005 Standard Edition or higher, Visual Basic or Visual C# Express, or Visual Web Developer edition; ReportViewer.exe redistributable installer for Express or Web Developer editions

Microsoft's Reporting Services add-on for SQL Server 2000 offered developers an effective and scalable alternative to Crystal Reports, Microsoft Access, or third-party reporting and charting add-ins for VS 2002/3.

ADVERTISEMENT

SQL Server 2005 integrates Reporting Services (SSRS) installation and configuration with the database server setup program and adds a Business Intelligence (BI) Projects node to VS 2005's New Projects dialog. BI reporting options include Report Model Project, Report Server Project, and Report Server Project Wizard. Report Models provide information workers with a business layer to simplify creation of ad hoc reports for a predefined data source. The new client-side Report Builder—a click-once WinForms application that users download from the Report Server—wants a Report Model as a starting point. Both Report Server project types use VS 2005's more versatile Report Designer UI to lay out tabular and crosstab (matrix) reports, charts, or any combination of reports and charts. Developers create and users open SSRS reports and models through the browser-based Report Manager.

.NET developers commonly add data-reporting features to smart-client and Web-based projects. Crystal Reports and several other third-party reporting add-ins offer VS 2005–compatible report controls but have more features than many projects need. SSRS is a standalone, server-based application that's likely to be overkill for applications that need to display, print, or export a few basic reports only. Microsoft admits in its SQL Server 2005 Express (SSX) white paper that "[c]reating reporting applications is often a cumbersome process" (see Additional Resources). SSRS is limited to SQL Server data sources only.

The new ReportViewer controls—introduced by VS 2005 beta 2—enable VS 2005 and Express Edition developers to design and then embed custom reports in WinForms and WebForms projects. ReportViewer controls ordinarily use a strongly typed or untyped DataSet's DataTable as a data source. You can create a ReportViewer data source from a query against any database with a native or OLE DB data provider, an XML document, or instances of business objects. You also can use the ReportViewer control to display, print, or export server-based SSRS reports. In this article, I'll show you how to get the most out of client-side ReportViewer controls and their Report Designer window. The downloadable VB 2005 sample code includes smart-client examples of tabular and crosstab reports generated from the AdventureWorks and Northwind sample databases.

Design and Embed a Local WinForm Report
You create a new local report in five steps: Create a new Windows application with a ReportViewer control; add a data source and an empty DataSet; add to the DataSet a TableAdapter with a Fill method query to define and populate a DataTable; add the report's header and data fields; and associate the report definition file with the ReportViewer control to display the initial report. I used the following steps to create the sample AWTestWinForm.sln project. You need SQL Server 2005 or SQL Express with the AdventureWorks 2005 sample database installed to run the project.

First, open a new Windows application in VS 2005, increase the size of Form1, and drag a ReportViewer control from the Toolbox's Data section to the form. The ReportViewer control consists of a pre-built ToolStrip above a report-viewing region and a ReportViewer Tasks smart tag. Select the Dock in Parent Container task to maximize the form's report-viewing area.




Back to top













Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home