Skip to main content

Bind a Report to Multiple Data Tables

  • 3 minutes to read

This tutorial shows you step-by-step how to include data from two (or more) unrelated data tables in a single report. In this topic, the data tables are from the same data source. For information on how to bind a report to different data sources, review the following help topic: Bind a Report to Multiple Data Sources.

  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, as described in the following help topic: Create a Report in Visual Studio.

  3. Add a data source with two unrelated tables. You can use the Employees and Products tables from the sample Northwind database. For more information on how to add a data source to the report, review the following help topic: Bind a Report to a Database.

    Multiple Data Tables - Add Data Source to Report

  4. Clear the DataSource and DataMember settings for the report. The settings should be assigned individually to the Detail Report bands, as described later.

    Multiple Data Tables - Clear Report Data Source

  5. Add a new Detail Report band. To do this, right-click on the Detail report band and select Insert Detail Report | Unbound in the context menu:

    Multiple Data Tables - Add Detail Report Band

  6. Specify the sqldataSource1 data source and Employees data member for the created DetailReport band:

    Multiple Data Tables - Specify Detail Report Band Data Source

  7. Add another new Detail Report band. To do this, right-click the Detail report band and select Insert Detail Report | Unbound in the context menu to create another DetailReportBand at the same level as the first Detail Report band.

    Multiple Data Tables - Add Another Detail Report Band

    Do not right-click a previously created Detail Report band and select Insert Detail Report, as this action creates a nested Detail Report band one level lower.

  8. Specify the sqldataSource1 data source and Products data member for the second DetailReport band:

    Multiple Data Tables - Specify Next Detail Report Band Data Source

  9. To force a page break between different data sets in a report, set the Band.PageBreak property of the first DetailReportBand to AfterBand:

    Multiple Data Tables - Set PageBreak to AfterBand

  10. Drag the FirstName and LastName fields from the Employees table in the Field List, and drop them onto the first Detail Report band:

    Multiple Data Tables - Add FirstName and LastName Fields

  11. Drag the ProductName field from the Products table in the Field List and drop it onto the first Detail Report band:

    Multiple Data Tables - Add ProductName Field

  12. Switch to the Preview tab and view the result.

    Multiple Data Tables - Resulting Report Preview

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.

See Also