Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

17.04 Create Dataset with the IDE

Using the IDE to Create a Dataset File

The Visual Studio IDE makes it easy to create a dataset file. Right-click on the menu Project | Add New Item. The Add New Item dialog box lists Dataset File as an option. Click on this option, give it an appropriate file name and click OK. The dataset file is created and added as an item in the Solution Explorer window. As you can see in Figure 17-1, the dataset is represented in the IDE as an empty screen.



Figure 17-1. The default Dataset designer surface.

At this point, the IDE is ready to build a new dataset file from scratch. Open the Server Explorer and drill down to the appropriate data source to find the table(s) you need. Drag one or more tables from the Server Explorer window onto the dataset surface. Behind the scenes the IDE generates the appropriate code to represent the table(s) with XML. To see what the XML source looks like without opening the file, right-click anywhere on the designer and select the option View XML Source.

The dataset has a dropdown box for the data type. You can click on this dropdown box to change the data type for the field. If you have a table that is similar to the dataset you want to create, but not exact, add it to dataset and make any changes to it. This is easier than creating the tables in the dataset from scratch.

Once finished adding the appropriate tables to the dataset your screen will look similar to the one in Figure 17-2.



Figure 17-2. The Dataset designer surface with two tables.

Clicking on the Save button in the toolbar causes the IDE to save the XML source to the dataset file. The file is ready to be linked to the report.

It is easy to forget to save the schema file before linking it to the report. But if you don’t save the file, the Report Expert won’t know what the fields are. It will show an empty table. There must be a physical .xsd file prior to running the Report Expert.