Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

1.01 Your First Report

Visual Studio .NET is the first Windows development environment that gives developers a fully integrated and robust reporting solution. Crystal Reports is now installed with Visual Studio so developers can write applications that have reports seamlessly integrated into them. Starting with Visual Basic 3.0, Crystal Reports was included with the language, but not part of the default installation. It was also a stand-alone product that was independent of the programming language.

Over the years Microsoft has been including Crystal Reports with each version of Visual Basic. With version 6 they even wrote a Data Report component that was supposed to be a replacement for Crystal Reports. But it failed miserably.

With the release of Visual Studio.NET, Microsoft finally woke up to the needs of developers. They licensed Crystal Decisions to write a version of Crystal Reports to be the default reporting solution installed with .NET. Built into the IDE, Windows developers now have the tools to write presentation-quality interactive reports.

Creating Your First Report

Before you learn about all the features of Crystal Reports, it is best to start by creating a quick report. This gives you a good overview of how easy it is to create a report as well as see some of its functionality in action. Open Visual Studio and create a new project. This can be either VB.NET or C#, and it can be either a Windows Application or ASP.NET. Designing reports with Crystal Reports is independent of the project type. The following steps are the same for both types of applications.

Once the project is open, select Project | Add New Item. This displays the list of available templates. For a Windows project, the left side has a Categories list where you can click on Reporting and then select Crystal Reports on the right. For an ASP.NET project, Crystal Reports is already near the top of the list of templates. After selecting the template, enter the name “Employee List”. Figure 1-1 shows this dialog box for a Windows Application. Click Add to create the report.



Figure 1-1. The Add New Item dialog box.

When the Crystal Report Gallery dialog box appears, accept the defaults of “Using the Report Wizard” and “Standard “. This is shown in Figure 1-2.



Figure 1-2. The Standard Report Expert dialog box.

The first page on the Crystal Reports Gallery dialog box is the Data page. Select the Xtreme Sample Database (it comes with Crystal Reports) by clicking on Create New Connectino and then the OLE DB(ADO) option in the Available Data Sources list. This brings up a new dialog box. Select Microsoft Jet 4.0 OLE DB Provider. On the next dialog box enter the database name (database name is the fully qualified file path). By default it is located at C:\Program Files\Microsoft Visual Studio 9.0\Crystal Reports\Samples\En\Databases. Select Finish.

You are back at the Data page of the expert. Click on the Tables node to expand and double-click on the Employee table name to move it to the window titled Selected Tables (or drag and drop it). Click Next.



Figure 1-3. The Data page of the report expert.

To display fields on the report, you have to select them on the Fields page. Double click on the following fields to add them to the right window: Employee ID, Last Name, and First Name. This is shown in Figure 1-4.



Figure 1-4. The Fields page of the report expert.

At this point you could continue with the report expert to do things such as grouping and selecting which records to print. But for this simple example, ignore those tabs and click Finish.

The report expert closes and builds a fully functioning report that is ready to run (Figure 1-5). If this report were to be used in a real application, the next step would be to modify the form so that it can preview and print the report.



Figure 1-5. Employee List report file in design mode.