Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

17.08 Populate the Dataset Object

Populate theDataSet Object

At this point in the process, you’ve created the proper dataset files and designed the report to use the datasets. If you run the report nothing is printed. This is because the datasets don’t have any data in them. You have to manually populate the datasets prior to opening the report.

Populating the dataset objects is coded differently for each type of data source you are connecting to. It is not within the scope of this book to discuss the best way to connect to a data source.

The code in this section shows the basic ways of populating a dataset for various data sources. Each procedure is called FillDataset() and takes an empty Dataset object. It populates it with the appropriate data. This procedure is called by the code in the next section “Bind the Dataset”.

The purpose of each of these procedures is to give you a quick way to copy and paste this code into your own application and quickly be productive. This should give you a good starting point and serve as a quick reference without having to look up the code in other books.

Within these examples, notice that the Fill() method of the DataAdapter object is always passed the table name. This is the name the report associates with each table. If you give a table an alias (discussed Chapter 13), then the Fill() method must be passed the original table name. You can’t pass the alias name to the Fill() method. Also note that per the documentation, the table name is case sensitive.