Allows you to customize connection settings before connecting to a database.
event ConfigureDataConnectionEventHandler ConfigureDataConnection
Event ConfigureDataConnection As ConfigureDataConnectionEventHandler
The ConfigureDataConnection event's data class is ConfigureDataConnectionEventArgs. The following properties provide information specific to this event:
|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.|
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.
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.