Skip to main content

Bind Reports to Data

  • 6 minutes to read

Single or Multiple Data Sources

You can bind a report only to a single data source. Only one data source can be assigned to the DataSource property. Most report groups and controls cannot be bound to a data source independently and use a report data source.

You can use a federated query to combine multiple data sources. For more information, review the following help topic: Data Federation.

If you need to use multiple data sources in one report, clear the report’s DataSource setting and add multiple DetailReportBand components to the report, where each DetailReportBand has its own data source. Another option is the XRSubreport control. For more information on how to bind a report to multiple data sources, review the following help topics:

Specify a Data Source in the Visual Studio Designer

Report Wizard

Invoke the Report Wizard to design a report bound to data. The Wizard allows you to select the data source type, create a connection, add queries, and create table relationships.

Data Source Wizard

Use the Data Source Wizard to bind a report to a data source. The Data Source Wizard allows you to select the data source type, create a connection, add queries, and create table relationships.

Note

Do not include dots in the name of a data source (for example, Customers.Products.2014 is incorrect). The report engine uses dots to separate the data source name from query names.

You can invoke the Data Source Wizard in one of the ways described below.

Report Smart Tag

Expand the Data Source combo box and click Add Report Data Source…

Bind Report to Data Source Designer Action

Properties Window

Expand the Data Source combo box and click Add Report Data Source…

Bind Report to Data Source Designer Properties Window

Report Explorer Window

Right-click the Data Sources (or Components) node and select Add Data Source.

Bind Report to Data Source Designer Report Explorer Window

Display Data Fields

The Field List window displays the available data fields after you connect a report to a data source. You can drop fields from the Field List onto the report design surface to create data-aware controls.

Bind Report to Data Field List

Note

Use the Rebuild Result Schema command or call the RebuildResultSchema method on any changes in the connection, queries, or database structure. The RebuildResultSchema method applies changes to the data source and refreshes fields available for report bindings and fields displayed in the field list.

Data Source Types (Runtime)

At runtime, you can assign any object to the DataSource property. When the report attempts to retrieve data from the associated data source, the report expects the data source object to support one of the following interfaces:

If this requirement is not met, an exception is thrown that informs the user that an object assigned to the DataSource property cannot be used as a report’s datasource, because it does not implement any of the supported interfaces.

The DevExpress Data Library ships with proprietary data access components that work as a proxy between your data and the report layout. These components are serializable, so they are automatically saved in the REPX report layout definition, making them part of your report layout. You can assign the following DevExpress Data Library objects to the DataSource property:

Manage Data Sources

You can add multiple data sources to a report:

Multiple Data Sources

A report stores the data sources in the ComponentStorage collection. The Field List window and the Data Source combobox in the Report Designer’s Properties panel display data sources contained in the ComponentStorage.

To display data in the report, you should assign a data source to the report’s DataSource property, DetailReportBand, or a data-bound report component, and specify the DataMember property when applicable.

When you create a reporting application, you might need to modify or configure data sources for your reports at runtime. Refer to the following topic for more information: Manage Data Sources at Runtime.

Reuse the Data Source

You can reuse a report’s data source in other reports. For this, add a report’s data source to the gallery, load another report, and add the data source from the gallery.

  1. Add a data source to the Report Gallery.

    Right-click a report’s data source in the Field List window (or Report Explorer window) and select Add to Gallery.

    design-time-field-list-data-source-add-to-gallery

  2. Assign a data source to a report.

    Open the Report Gallery window. Right-click the data source in the Data Sources node and select Add to Report Components.

    report-gallery-apply-component-template

Parent Data Source

The report’s DataSource property specifies the parent data source. When you assign a data source to the report’s DataSource property, it may affect all report elements. Report elements to which a data source can be assigned (controls, bands, parameters, calculated fields) use the data source of the report that contains them (the parent report) if their DataSource property is not specified.

You can assign a different data source to the DetailReportBand to create a master-detail report, as described in the following help topic: Create a Master-Detail Report with a Detail Report Band in the VS Report Designer.

Typically, you should explicitly specify the data source and data member for the following report controls:

You can use the DataSourceManager.GetDataSourceAssignables method to obtain a collection of all report elements that can be bound to a data source.

Schema-Only Mode

You can use the DataSourceSchema property to specify a data source schema and bind report controls to data fields, even if the data is not available at the time you edit the report.

Supported Data Sources

DevExpress Reporting allows you to bind reports to the following data sources:

Bind Reports to Data in the End-User Report Designer

Tutorials that explain how to use this functionality in EUD Report Designers for WinForms and Web are included in the End-User Documentation online help section: