xtrareports-devexpress-dot-xtrareports-dot-datasourcemanager-dot-getdatasources-x28-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-system-dot-boolean-x29.md
Returns all report data sources.
Namespace : DevExpress.XtraReports
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public static IEnumerable<object> GetDataSources(
XtraReport report,
bool includeSubReports = false
)
Public Shared Function GetDataSources(
report As XtraReport,
includeSubReports As Boolean = False
) As IEnumerable(Of Object)
| Name | Type | Description |
|---|---|---|
| report | XtraReport |
A report instance.
|
| Name | Type | Default | Description |
|---|---|---|---|
| includeSubReports | Boolean | False |
true to include data sources from subreports; otherwise, false.
|
| Type | Description |
|---|---|
| IEnumerable<Object> |
A collection of report data sources.
|
The following code sample shows how to get all report data sources (except for subreport data sources), iterate through these data sources, and update settings (the ConnectionName property) of each data source whose type is SqlDataSource.
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports;
//...
var report = new XtraReport1();
var dataSources = DataSourceManager.GetDataSources(report, includeSubReports: false);
foreach (var dataSource in dataSources) {
if (dataSource is SqlDataSource) {
(dataSource as SqlDataSource).ConnectionName = "nwind";
}
}
Imports DevExpress.DataAccess.Sql
Imports DevExpress.XtraReports
'...
Private report = New XtraReport1()
Private dataSources = DataSourceManager.GetDataSources(report, includeSubReports:= False)
For Each dataSource In dataSources
If TypeOf dataSource Is SqlDataSource Then
TryCast(dataSource, SqlDataSource).ConnectionName = "nwind"
End If
Next dataSource
See Also