ADO WillConnect, ConnectComplete, and Disconnect events

Definition and Usage

Events are subroutine calls that are automatically invoked after a specific operation is performed.

  • The WillConnect event is triggered before the connection starts.
  • The ConnectComplete event is triggered after the connection starts.
  • The Disconnect event is triggered after the connection is ended.

Syntax

WillConnect ConnectionString, userid, psword, options, status, objcon
ConnectComplete objerror, status, objconn
Disconnect status, objconn
Parameters Description
ConnectionString A string containing the information used for the connection.
userid A string containing the username used for the connection.
psword A string containing the password used for the connection.
options A Long value indicating the method used by the provider to calculate the ConnectionString. The only option is adAsyncOpen.
objerror

The Error object containing the errors that have occurred.

Note:EventStatusEnum The value must be set to adStatusErrorsOccurred to create an Error object.

status

One EventStatusEnum Value. The default is adStatusOK.

When calling ConnectComplete, if the WillConnect event requests to cancel the suspended connection, this parameter will be set to adStatusCancel.

objconn Apply this event's Connection Object.

EventStatusEnum Value

Constant Value Description
adStatusOK 1 The operation that triggered this event was successful.
adStatusErrorsOccurred 2 The operation that triggered this event failed.
adStatusCantDeny 3 Cannot cancel the suspended operation.
adStatusCancel 4 Cancel the operation that caused the event.
adStatusUnwantedEvent 5 Prevent subsequent notifications before the execution of the event method.