This is the third part of a three-part series examining the new features in Visual Studio 2005, focusing on Crystal Reports. Part 1 of this series introduced you to the sample application design, new features in Crystal, and some sample code for the admin application. Part 2 goes over the mechanics of creating a report using stored procedures.
In this final part, I will go over binding an object to the report, rather than a query or a stored procedure. As more developers create business objects for applications, this may be something that a report designer may want to take advantage of. This part of the sample application will use an automatically created object (a DataSet). I will show how I created the report, and then how I created the business object as the data source for the report. Finally, I'll demonstrate populating the business object in a web page, allowing users to view a report bound to a business object.
System Requirements
I developed this part of the sample application using Windows XP Service Pack 2, SQL Express 2005 (which is included with Visual Studio Team Suite) April CTP, and Visual Studio Team Suite Beta 2. The exciting thing about the Beta 2 for Visual Studio is that it includes a go live license, so it can be used now for a live site. I am assuming that the reader is familiar with ASP.NET, Crystal Reports .NET, SQL Server, and ADO.NET.
To set up the database used in the application, do the following. In the download, a backup of the FFAsistant database is included. To restore the backup to your version of SQL 2005 Express, execute this command at a command prompt.
Listing 1: SQL Command to install Database
osql -SSERVERNAME\SQLEXPRESS -dFFAssistant -E -q"RESTORE DATABASE
TestDB FROM DISK = 'c:\ffassistantbak.dat'”
This should set up the sample database for you with some data in the tables, and the correct table structure. All code assumes that you use integrated Windows security to access the data.
To set up the Project Files, follow the Readme file included with the download.