IDashboardControl.ConfigureDataConnection Event
Allows you to customize connection settings before the DashboardViewer/DashboardDesigner connects to a data store (database, OLAP cube, etc.).
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v24.2.Win.dll
NuGet Package: DevExpress.Win.Dashboard
#Declaration
event DashboardConfigureDataConnectionEventHandler ConfigureDataConnection
#Event Data
The ConfigureDataConnection event's data class is DashboardConfigureDataConnectionEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Connection |
Gets the name of the connection for which the event has been raised.
Inherited from Configure |
Connection |
Gets or sets parameters used to establish a connection to data.
Inherited from Configure |
Data |
Gets the data source name for which the event was raised. |
#Remarks
The ConfigureDataConnection event occurs before connecting to a data source and allows you to customize connection settings.
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
If the dashboard is bound to the DashboardObjectDataSource, the IDashboardControl.DataLoading event fires instead.
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 Sql To specify other data provider parameters, cast an object to any of the types listed in the DevExpress.
You can also add a custom connection string. Cast an object to the Custom Tip You can use a custom connection string to get data from an XML file that contains valid schema, for example, “xpoprovider=In | |
Cast an object to the Olap | |
Cast an object to the Excel | |
Cast an object to the Extract | |
Event does not occur. | |
Event does not occur. Handle the Data
| |
Cast an object to the Json You can also add a custom connection string. Cast an object to the Custom | |
Cast an object to the Mongo |
Tip
Refer to the following topic for information about custom connection strings: Custom Connection Strings for Data Sources
The following code snippet shows how to handle the ConfigureDataConnection event for various data source types:
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
// ...
dashboardControl.ConfigureDataConnection += dashboardControl_ConfigureDataConnection;
// ...
private void dashboardControl_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e){
if (e.DataSourceName == "sqliteDataSource"){
SQLiteConnectionParameters parameters = e.ConnectionParameters as SQLiteConnectionParameters;
if (parameters != null){
parameters.FileName = "file:Data\nwind.db";
parameters.Password = "test";
}
}
if (e.DataSourceName == "olapDataSource"){
OlapConnectionParameters parameters = e.ConnectionParameters as OlapConnectionParameters;
if (parameters != null){
parameters.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;"
+ "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;";
}
}
if (e.DataSourceName == "extractDataSource"){
ExtractDataSourceConnectionParameters parameters = e.ConnectionParameters as ExtractDataSourceConnectionParameters;{
if (parameters != null){
parameters.FileName = "file:Data\nwind.dat";
}
}
}
if (e.DataSourceName == "oracleDataSource"){
OracleConnectionParameters parameters = e.ConnectionParameters as OracleConnectionParameters;
if (parameters != null){
parameters.ProviderType = OracleProviderType.ODPManaged;
parameters.ServerName = "dashboarddb:1521/OracleTest";
parameters.UserName = "user";
parameters.Password = "test";
}
}
if (e.DataSourceName == "excelDataSource"){
ExcelDataSourceConnectionParameters parameters = e.ConnectionParameters as ExcelDataSourceConnectionParameters;
if (parameters != null){
parameters.FileName = "file:Data\nwind.xlsx";
parameters.Password = "test";
}
}
}