SQL Data Source

  • 2 minutes to read

This tutorial shows how to add the DashboardSqlDataSource to an in-memory data source storage, and make it available to users. The sample SQLite database supplies the dashboard with data.

  1. In your application, create the Data folder and add the nwind.db database to it from the C:\Users\Public\Documents\DevExpress Demos 21.2\Components\Data folder.

  2. In the Startup.cs file, create a public method that returns the configured dashboard’s data source storage (DataSourceInMemoryStorage).

    using DevExpress.DataAccess.Sql;
    public DataSourceInMemoryStorage CreateDataSourceStorage() {
        DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
               DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "sqliteConnection");
                sqlDataSource.DataProcessingMode = DataProcessingMode.Client;
                DevExpress.DataAccess.Sql.SelectQuery query = DevExpress.DataAccess.Sql.SelectQueryFluentBuilder
                    .Build("Sales Person");
                dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());         
        return dataSourceStorage;
  3. Call the DashboardConfigurator.SetDataSourceStorage method to configure the data source storage. Use the created CreateDataSourceStorage method as the SetDataSourceStorage parameter. Then subscribe to the DashboardConfigurator.ConfigureDataConnection event to pass the connection parameters the SQL data source requires.

    using DevExpress.AspNetCore;
    using DevExpress.DashboardAspNetCore;
    using DevExpress.DashboardWeb;
    public void ConfigureServices(IServiceCollection services) {
        services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
            DashboardConfigurator configurator = new DashboardConfigurator();
            // ...
            configurator.ConfigureDataConnection += Configurator_ConfigureDataConnection;
            return configurator;
  4. Specify the connection parameters at runtime in the DashboardConfigurator.ConfigureDataConnection event handler.

    using DevExpress.DataAccess.ConnectionParameters;
    private void Configurator_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
        if (e.ConnectionName == "sqliteConnection") {
            SQLiteConnectionParameters sqliteParams = new SQLiteConnectionParameters();
            sqliteParams.FileName = "file:Data/nwind.db";
            e.ConnectionParameters = sqliteParams;
  5. As a result, the SQL Data Source is displayed as a Web Dashboard’s predefined data source.


Users can now bind dashboard items to data in the Web Dashboard’s UI.


The example shows how to make a set of data sources available for users in the Web Dashboard application.

View Example: How to Register Data Sources for ASP.NET Core Dashboard Control