DashboardConfigurator.SetConnectionStringsProvider(IDataSourceWizardConnectionStringsProvider) Method

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

Namespace: DevExpress.DashboardWeb

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

Declaration

public void SetConnectionStringsProvider(
    IDataSourceWizardConnectionStringsProvider provider
)
Public Sub SetConnectionStringsProvider(
    provider As IDataSourceWizardConnectionStringsProvider
)

Parameters

Name Type Description
provider IDataSourceWizardConnectionStringsProvider

An object that implements the IDataSourceWizardConnectionStringsProvider interface and provides access to the predefined connections strings.

Remarks

Pass the ConfigFileConnectionStringsProvider instance (DashboardConnectionStringsProvider for ASP.NET Core) as a method's parameter for a default connection string provider implementation to allow end users to create new data sources based on predefined connection strings.

using DevExpress.DashboardWeb;
using DevExpress.DataAccess.Web;
// ...
DashboardConfigurator.Default.SetConnectionStringsProvider(new ConfigFileConnectionStringsProvider());
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());
        }
        // ...
    }
}
See Also