Skip to main content
A newer version of this page is available. .

Bind a Report to Multiple Data Sources

  • 2 minutes to read

You can bind the following report elements to individual data sources, independent of the report’s data source:

This topic demonstrates how to do this.

Tip

To learn how to bind a report to multiple non-related tables from the same data source, see Bind a Report to Multiple Data Tables.

To bind a report to different data sources, do the following.

  1. Start Microsoft Visual Studio 2010, 2012, 2013, 2015 or 2017 and create a new application under any of the supported platforms, or open an existing one.
  2. Add a new blank report to it.
  3. To add a DetailReport band to the report, right-click anywhere over the report’s surface, and on the invoked menu, point to Insert Detail Report and click Unbound.

    HowTo - BindReportToDifferentDataSources_0

  4. To bind the band to a data source, click its smart tag, and in the invoked actions list, expand the Data Source drop-down list and click Add Report Data Source…

    HowTo - BindReportToDifferentDataSources_1

    Then, the Data Source Wizard will guide you through the process of assigning the data source to the band. These steps are similar to the ones described in the following topic: Bind a Report to a Database.

  5. In this example, the DetailReport band is bound to the “Employees” table of the sample Northwind database (the nwind.mdb file is shipped with the XtraReports installation).

    After performing the steps above, the XtraReportBase.DataSource property of the DetailReport band is set to sqlDataSource1. It is also required that you set the band’s XtraReportBase.DataMember property to the Employees table of the dataset.

    HowTo - BindReportToDifferentDataSources_2

    Now, the detail report is bound to the data.

  6. Next, create another DetailReport band and repeat the same steps as above to bind it to another data source (the “Suppliers” data table of the same Northwind database).

    Note

    Though in this example the second DetailReport band is bound to the same database, it is still possible to choose an absolutely different data source for it.

  7. As in this example, you don’t need the Detail band to show any data, so hide it by setting its Visible property to False.
  8. Now, from the Field List‘s corresponding DataSources, drop the required data fields onto the appropriate bands.

    HowTo - BindReportToDifferentDataSources_3

The report is now ready. Switch to the Preview tab and view the result.

HowTo - BindReportToDifferentDataSources_4