DashboardControl.ConfigureDataConnection Event
Allows you to customize connection settings before the DashboardControl connects to a data store (database, OLAP cube, etc.).
Namespace: DevExpress.DashboardWpf
Assembly: DevExpress.Dashboard.v24.1.Wpf.dll
NuGet Package: DevExpress.Wpf.Dashboard
Declaration
Event Data
The ConfigureDataConnection event's data class is DashboardConfigureDataConnectionEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ConnectionName | Gets the name of the connection for which the event has been raised. Inherited from ConfigureDataConnectionEventArgs. |
ConnectionParameters | Gets or sets parameters used to establish a connection to data. Inherited from ConfigureDataConnectionEventArgs. |
DataSourceName | Gets the data source name for which the event was raised. |
Remarks
The ConfigureDataConnection event is raised before the connection to a data store is established and allows you to customize connection settings.
To specify connection parameters, cast an object the e.ConnectionParameters property returns to the DataConnectionParametersBase descendant. The following table lists the different data sources and their corresponding descendants:
Data Source | Parameter Type |
---|---|
The SqlServerConnectionParametersBase class is the base type and defines the basic connection parameters: DatabaseName, Password, ServerName and UserName. To specify other data provider parameters, cast an object to any of the types listed in the DevExpress.DataAccess.ConnectionParameters namespace. Here are some of the types:
You can also add a custom connection string. Cast an object to the CustomStringConnectionParameters class and assign a custom connection string to the ConnectionString property. Tip You can use a custom connection string to get data from an XML file that contains valid schema, for example, “xpoprovider=InMemoryDataStore;data source=””your_data_file.xml””;read only=True” | |
Cast an object to the OlapConnectionParameters type and use the ConnectionString property. | |
Cast an object to the ExcelDataSourceConnectionParameters type and use the FileName and Password properties. | |
Cast an object to the ExtractDataSourceConnectionParameters type and use the FileName and DriverName properties. | |
Event does not occur. | |
Event does not occur. Handle the DataLoading/AsyncDataLoading event instead:
| |
Cast an object to the JsonSourceConnectionParameters type and use the JsonSource property. You can also add a custom connection string. Cast an object to the CustomStringConnectionParameters class and assign a custom connection string to the ConnectionString property. | |
Cast an object to the MongoDBCustomConnectionParameters type and use the following connection parameters: |
Tip
Refer to the following topic for information about custom connection strings: Custom Connection Strings for Data Sources
This event is raised when the dashboard is supplied with data using one of the following data source types:
- DashboardSqlDataSource
- DashboardOlapDataSource
- DashboardExcelDataSource
- DashboardExtractDataSource
- DashboardJsonDataSource
- DashboardMongoDBDataSource
Note
If the dashboard is supplied with data using the DashboardObjectDataSource data source, the DashboardControl.AsyncDataLoading event is fired instead.
The following example shows how to specify connection parameters for an SQL Data Source:
private void dashboardControl_ConfigureDataConnection(object sender, DevExpress.DashboardCommon.DashboardConfigureDataConnectionEventArgs e) {
//...
e.ConnectionParameters = new MsSqlConnectionParameters("serverName", "databaseName", "user", "password", MsSqlAuthorizationType.SqlServer);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ConfigureDataConnection event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.