Register Default Data Sources
- 2 minutes to read
This document describes how to provide a Web Dashboard with a set of default data sources available for end-users.
You can create the data sources at runtime. The Web Dashboard supports the following data source types:
- SQL data source
- OLAP data source
- Excel data source
- Object data source
- Entity Framework data source
- Extract data source
- JSON data source
- XPO data source
- Federated data source
After you create the data sources, register them in the data source storage. For this, use the ASPxDashboard.SetDataSourceStorage or DashboardConfigurator.SetDataSourceStorage method (the selected method depends on the server-side API used). You can utilize a predefined implementation of the in-memory storage (DataSourceInMemoryStorage) or implement the IDataSourceStorage interface to allow custom data source storage.
The following code snippet shows how to create the in-memory storage of data sources for the Web Designer.
DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "sqlConnection");
SelectQuery countriesQuery = SelectQueryFluentBuilder
.AddTable("Countries")
.SelectColumns("Country", "Latitude", "Longitude", "Year", "EnergyType", "Production", "Import")
.Build("Countries");
sqlDataSource.Queries.Add(countriesQuery);
DashboardOlapDataSource olapDataSource = new DashboardOlapDataSource("OLAP Data Source", "olapConnection");
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
dataSourceStorage.RegisterDataSource("sqlDataSource1", sqlDataSource.SaveToXml());
dataSourceStorage.RegisterDataSource("olapDataSource1", olapDataSource.SaveToXml());
ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
Protect User Data
The Web Dashboard saves user credentials used by data sources to the dashboard XML definition.
Use the DashboardConfigurator.PassCredentials property to specify whether to pass this information to the client side (web browser). Set this property to false and specify connection parameters in one of the following ways to avoid any security issues:
- Add the connection string to the connectionStrings section in the Web.config file and specify the connection parameters.
- Implement the IDataSourceWizardConnectionStringsProvider interface to create a data connections provider. Pass the created provider as the ASPxDashboard.SetConnectionStringsProvider/DashboardConfigurator.SetConnectionStringsProvider method’s parameter.
- Handle the ASPxDashboard.ConfigureDataConnection/DashboardConfigurator.ConfigureDataConnection event to specify the connection parameters at runtime.