Skip to main content

Bind a Report to Multiple Data Sources

  • 2 minutes to read

You can bind the following report elements to data sources other than the report’s data source:

This topic shows how to bind two DetailReport bands to different data sources. Follow the steps outlined below.

  1. Create a new application or open an existing application. For more information, review the following help topic: Get Started with DevExpress Reporting.

  2. Add a new blank report to it.
  3. Add a DetailReport band to the report: select Insert Detail Report/Unbound in the context menu:

    Bind a Report to Multiple Data Sources - Insert a Band

  4. Bind the added band to a data source. Click the smart tag, expand the Data Source drop-down list, and click Add Report Data Source.

    Bind a Report to Multiple Data Sources - Specify the First Data Source

    The invoked Data Source Wizard guides 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, bind the Detail Report band to the Employees table from the sample Northwind database.

    Once you complete the above steps, the DetailReport band’s DataSource property is set to sqlDataSource1. Then set the band’s DataMember property to the dataset’s Employees table.

    Bind a Report to Multiple Data Sources - Specify the First Data Member

  6. Create another Detail Report band at the same detail level. To do so, right-click the report design area outside the previously created Detail Report band and select Insert Detail Report/Unbound in the context menu. Review this newly created DetailReport band in the following image:

    Bind a Report to Multiple Data Sources - Add the Second Detail Band

  7. Proceed with the same steps as described above to bind the second Detail Band to a different data source. In this example, the second data source is the Northwind database’s Suppliers table:

    Bind a Report to Multiple Data Sources - Specify the Second Data Source

  8. In this example, you do not need to show any data in the Detail band. Set the Detail band’s Visible property to False to hide it:

    Bind a Report to Multiple Data Sources - Hide Detail Band

  9. Insert a Report Header band into each Detail Report band:

    Bind a Report to Multiple Data Sources - Insert Report Header Band

  10. Add label controls to report header bands. Drop data fields from the Field List onto detail report bands:

    Bind a Report to Multiple Data Sources - Insert Report Header Band

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

Bind a Report to Multiple Data Sources - Result

Tip

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.