dashboard-402946-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-providing-data-sql-data-source-save-connection-parameters.md
The Dashboard Designer does not save the username and password automatically after a successful connection to a database. For security reasons, the Dashboard Designer prompts a user to enter credentials for each connection because the dashboard definition does not encrypt credentials. If you want the application to connect to a database without user interaction, use one of the following techniques:
Save database credentials in a dashboard definition.
Specify connection parameters in code before a dashboard is opened.
To save database credentials in a dashboard definition, set the SqlWizardSettings.DatabaseCredentialsSavingBehavior property to one of the following values:
Always Database credentials are always serialized with document layouts. Users cannot change this behavior. Prompt
Users can select whether to save database credentials in the Data Source wizard. The following dialog appears once a user specifies connection parameters and clicks Next :
Refer to the following help topic for more information on how to create a connection to SQL databases in the Data Source Wizard: Connecting to SQL Databases.
If you do not want to store connection parameters in a dashboard, handle the DashboardDesigner.DashboardSaving event to remove connection parameters before a dashboard is saved. Then, implement another connection parameter storage mechanism as described in the sections below.
The code snippets below show how you can clear Oracle database connection parameters from a dashboard xml file before a dashboard is saved:
Assign a new DevExpress.DataAccess.ConnectionParameters.OracleConnectionParameters instance to the SqlDataSource.ConnectionParameters property to clear out connection information.
Use the DataConnectionBase.StoreConnectionNameOnly property to store only the data connection’s name.
The DashboardDesigner.ConfigureDataConnection event allows you to pass authentication credentials used to connect the Dashboard Designer to a database without user interaction. The event occurs before the Dashboard Designer connects to a data store.
To specify connection parameters, cast the e.ConnectionParameters property value to a DataConnectionParametersBase descendant.
The following code snippet shows how to connect to an Oracle database before the dashboard is loaded:
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
//...
private void DashboardDesigner_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e){
OracleConnectionParameters parameters = e.ConnectionParameters as OracleConnectionParameters;
if (parameters != null){
parameters.ProviderType = OracleProviderType.ODPManaged;
parameters.ServerName = "dashboarddb:1521/OracleTest";
parameters.UserName = "northwind";
parameters.Password = "test";
}
}
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
'...
Private Sub DashboardDesigner_ConfigureDataConnection(ByVal sender As Object, ByVal e As DashboardConfigureDataConnectionEventArgs)
If e.ConnectionName = "oracleConnection" Then
Dim parameters As New OracleConnectionParameters()
parameters.ProviderType = OracleProviderType.ODPManaged
parameters.ServerName = "dashboarddb:1521/OracleTest"
parameters.UserName = "northwind"
parameters.Password = "test"
End If
End Sub
This mode enables Windows Authentication and disables SQL Server Authentication. When a user uses a Windows account to authenticate in an SQL Server, the Windows principal token is used to validate the account name and password. The SQL server does not request a password or perform identity validation because the operating system confirms the user identity.
Windows Authentication mode is available for databases deployed on the Microsoft SQL Server.
The Data Source Wizard allows users to select the Authentication type in the following dialog:
In code, set the MsSqlConnectionParameters.AuthorizationType property to Windows :
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
// ...
MsSqlConnectionParameters msSqlParams = new MsSqlConnectionParameters();
msSqlParams.AuthorizationType = MsSqlAuthorizationType.Windows;
msSqlParams.ServerName = "localhost";
msSqlParams.DatabaseName = "Northwind";
DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("Data Source 1", msSqlParams);
//...
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
' ...
Private msSqlParams As New MsSqlConnectionParameters()
msSqlParams.AuthorizationType = MsSqlAuthorizationType.Windows
msSqlParams.ServerName = "localhost"
msSqlParams.DatabaseName = "Northwind"
Dim sqlDataSource As New DashboardSqlDataSource("Data Source 1", msSqlParams)
'...