reating reports is one of the most common things developers are asked to do when building a typical business application. Businesses want to know how well a product has sold, the sales total for the month, the inventory status, etc. All these require specialized tools for easily generating the reports. And developers who are migrating from Visual Basic 6 would be happy to know that the Crystal Report they have been familiar with, is now available on Visual Studio 2005.
This article shows you how to get started with Crystal Report for Visual Studio 2005. You'll learn how to create simple reports and how to add charts to your reports.
Creating a Report
To see the power of Crystal Report for Visual Studio 2005, let's first create a report that shows some customers' order information stored in the Northwind sample database. Figure 1 shows the sample report that you will create.
Installing the Sample Database
Since SQL Server 2005 Express does not come with any sample databases, you need to install the sample databases yourself.
You can install the Northwind sample databases by downloading their installation scripts here.
Once you've installed the scripts on your system, go to the Visual Studio 2005 Command Prompt (from the Start menu, choose Programs, Microsoft Visual Studio 2005, and then Visual Studio Tools, and finally Visual Studio 2005 Command Prompt) and change to the directory containing your installation scripts. Type in the following to install the Northwind database:
C:\SQL Server 2000 Sample Databases>sqlcmd -S .\SQLEXPRESS -i instnwnd.sql
Figure 1. The Sample Report: This report shows some customers order information stored in a Northwind sample database.
Figure 2. Table Relationships: The relationships of the four tables in the Northwind database.
As you can see, the products ordered by each company are listed, together with each product's unit price and quantity ordered. In addition, report shows the country where the product is being shipped. All the relevant data are stored in the following four tables in the Northwind database:
- Order Details
The four tables are related in the following manner (see Figure 2