DashboardConfigurator.SetConnectionStringsProvider(IDataSourceWizardConnectionStringsProvider) Method

Specifies a provider of data connections that can be used by the Web Dashboard.

Namespace: DevExpress.DashboardWeb

Assembly: DevExpress.Dashboard.v18.1.Web.dll

Syntax

public void SetConnectionStringsProvider(
    IDataSourceWizardConnectionStringsProvider provider
)

Parameters

Type Name Description
IDataSourceWizardConnectionStringsProvider provider

An object implementing the IDataSourceWizardConnectionStringsProvider interface.

Important

To learn how to use the DashboardConfigurator's API, see the Server-Side API Overview topic.

This example shows how to implement a custom provider of connection strings by implementing the IDataSourceWizardConnectionStringsProvider interface.

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Native;
using DevExpress.DataAccess.Web;
// ...

    public class MyDataSourceWizardConnectionStringsProvider : IDataSourceWizardConnectionStringsProvider
    {
        public Dictionary<string, string> GetConnectionDescriptions() {
            Dictionary<string, string> connections = new Dictionary<string, string>();

            // Customize the loaded connections list.  
            connections.Add("msAccessConnection", "MS Access Connection");
            connections.Add("msSqlConnection", "MS SQL Connection");
            return connections;
        }

        public DataConnectionParametersBase GetDataConnectionParameters(string name) {
            // Return custom connection parameters for the custom connection.
            if (name == "msAccessConnection") {
                return new Access97ConnectionParameters("|DataDirectory|nwind.mdb", "", "");
            } else if (name == "msSqlConnection") { 
                return new MsSqlConnectionParameters("localhost", "Northwind", "", "", MsSqlAuthorizationType.Windows);
            } 
            throw new System.Exception("The connection string is undefined.");
        }
    }

After you have implemented a custom provider of connection strings, pass the instance of this class to the DashboardConfigurator.SetConnectionStringsProvider method.

using DevExpress.DashboardWeb;
// ...
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            // ...
            DashboardConfigurator.Default.SetConnectionStringsProvider(new MyDataSourceWizardConnectionStringsProvider());
        }
        // ...
    }
}