SnapDocument.ConfigureDataConnection Event
Allows you to customize connection settings before connecting to a database.
Namespace: DevExpress.Snap.Core.API
Assembly: DevExpress.Snap.v21.2.Core.dll
NuGet Package: DevExpress.Snap.Core
Declaration
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
This event is intended to correctly process documents, whose multiple instances are opened (e.g., when loading the same SNX file on multiple client machines, and each client is individually connected to the corresponding database using its own credentials). Handling this event is not required when the Query Designer is used to create a new data source from scratch, because the connection string is automatically assigned a unique name.
Note
When the SnapDocument is connected to a database using the Query Builder, this event fires if the data source has been restored from the SNX file. If the data source was created using the Query Designer at runtime, this event does not fire.
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).
- To identify the connection for which the event is raised, use the event parameter’s ConfigureDataConnectionEventArgs.ConnectionName property.
To access connection parameters, use the ConfigureDataConnectionEventArgs.ConnectionParameters property.
This 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.
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ConfigureDataConnection event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.