Skip to main content
A newer version of this page is available. .

SqlDataSource.ConfigureDataConnection Event

Allows you to customize connection settings before connecting to a database.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v18.2.dll

Declaration

public event ConfigureDataConnectionEventHandler ConfigureDataConnection

Event Data

The ConfigureDataConnection event's data class is ConfigureDataConnectionEventArgs. The following properties provide information specific to this event:

Property Description
ConnectionName Gets the name of the connection for which the event has been raised.
ConnectionParameters Gets or sets parameters used to establish a connection to data.

Remarks

The ConfigureDataConnection event is fired each time the SqlDataSource connects to a database. Handle this event to change parameters required to establish a connection to data (for instance, the server name, the database name, user credentials, the path to a data file, etc).

Tip

For a code sample, see the following example online: SqlDataSource - How to change connection parameters at runtime.

Use the event parameter’s ConfigureDataConnectionEventArgs.ConnectionName property to identify the connection for which the event is raised. To access connection parameters, use the ConfigureDataConnectionEventArgs.ConnectionParameters property.

The ConfigureDataConnectionEventArgs.ConnectionParameters property returns a DataConnectionParametersBase descendant. Different DataConnectionParametersBase descendants provide connection parameters for different DBMS and data file formats. For instance, the MsSqlConnectionParameters, OracleConnectionParameters, XmlFileConnectionParameters and many other classes are available.

To edit current connection parameters, cast the returned DataConnectionParametersBase object to an appropriate descending type and then adjust the parameters. To change the data provider, create an object of an appropriate descending type, customize the parameters and assign the created object to the ConfigureDataConnectionEventArgs.ConnectionParameters property.

See Also