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.
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.
- 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.
- Add a new blank report to it.
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.
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…
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.
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.
Now, the detail report is bound to the data.
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).
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.
- 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.
Now, from the Field List‘s corresponding DataSources, drop the required data fields onto the appropriate bands.
The report is now ready. Switch to the Preview tab and view the result.