Bind a Report to Standard .NET Data Providers

This topic explains how to bind reports to data using standard .NET data providers at design time and runtime.

Tip

You can use this approach when the SqlDataSource does not meet your requirements (for example, when you need to bind your report to an OLE DB provider or an existing DataSet object).

See the Quick Guide to Report Data Binding topic to learn about the other data binding approaches.

Create the following objects to connect a report to a .NET data provider:

  • A data connection specifying the database's location and the method for accessing it.
  • A data adapter that serves as a bridge between physical data and a dataset. It uses the data connection object to access a database.
  • Once a data adapter has been created and configured, it can generate a DataSet which supplies the report with the actual data.

The following image illustrates the data binding mechanism described above:

DataBinding - NetAdapters

.NET data providers allow you to access standard data types which use different connections and data adapters:

Tip

You can also use different third-party data adapters if they can generate and populate a report's dataset.

You can bind a report to a DataSet in the following ways:

You need to fill the dataset with data manually by calling the data adapter's Fill method. For instance, you could do this before previewing or printing the report. However, you can avoid manually filling the dataset by setting the XtraReportBase.DataAdapter property to the data adapter that was used to create the dataset. In this case, the report automatically populates the dataset with data.

Tip

It is possible to load only a predefined number of records from a dataset, which can reduce the load on your database server and the time it takes to generate a report when working with large datasets.

Use the XtraReport.PreviewRowCount property to limit the number of data records displayed in a report. It is set to zero value by default, meaning that this property is ignored.

When a bound data source contains more than one data table, you can use the XtraReportBase.DataMember property to specify the list in the data source (normally, this is a table) whose data is used by a report control. This property is set automatically in most cases, but you can change its value if required.