Description
| This event is called before a pending command is executed.It allows you to change the execution parameters.
The WillExecute event can be fired just before a Command Execute, Connection Execute, or Recordset Open method starts to execute. This event is one of two command execution management events that can be called. The other event is ExecuteComplete.
An event is simply a subroutine that can be called automatically after a specific operation has occurred. This subroutine can contain any code that you need to run when the event occurs. The subroutine will only be called if it is included in your code. Future calls to the event subroutine can be cancelled by setting the adStatus parameter to be the adStatusUnwantedEvent constant (see table below) before the event returns.
There are eight parameters that are passed to this event.
Parameter
| Description
| Source
| The Source parameter is a string that contains either an SQL command or a stored procedure name.
| CursorType
| The CursorType parameter is a long value that is one of CursorTypeEnum constants.
| LockType
| The LockType parameter is a long value that is one of LockTypeEnum constants.
| Options
| The Options parameter is a long value that is one or more of the CommandTypeEnum or ExecuteOptionEnum constants. It comes from the Options parameter of the Command Execute, Connection Execute, or Recordset Open methods.
| adStatus
| The adStatus parameter defines the status of the event and is set to either the adStatusOK or the adStatusCantDeny values of the EventStatusEnum constants. Before the event returns, to prevent unwanted future firings of this event, set this parameter to adStatusUnwantedEvent, or set it to adStatusCancel to cancel the operation that fired the event.
| pCommand
| The pCommand parameter is set either to the Command object that was executed or to Nothing.
| pRecordset
| The pRecordset parameter is set either to the Recordset object that resulted from the execution of the command or to Nothing.
| pConnection
| The pConnection parameter is the Connection object that is associated with the execution.
|
CursorTypeEnum constants
Constant
| Value
| Description
| adOpenDynamic
| 2
| Provides a dynamic cursor
| adOpenForwardOnly
| 0
| Default, provides a forward-only cursor
| adOpenKeyset
| 1
| Provides a keyset cursor
| adOpenStatic
| 3
| Provides a static cursor
| adOpenUnpecified
| -1
| Unspecified
|
LockTypeEnum Constants
Constant
| Value
| Description
| adLockBatchOptimistic
| 4
| Multiple users can modify the data and the changes are cached until BatchUpdate is called
| adLockOptimistic
| 3
| Multiple users can modify the data which is not locked until Update is called
| adLockPessimistic
| 2
| The provider locks each record before and after you edit, and prevents other users from modifying the data
| adLockReadOnly
| 1
| Read-only data
| adLockUnspecified
| -1
| Lock type unknown
|
CommandTypeEnum Constants
Constant
| Value
| Description
| adCmdFile
| 256
| Evaluate as a previously persisted file
| adCmdStoredProc
| 4
| Evaluate as a stored procedure
| adCmdTable
| 2
| Have the provider generate a SQL query and return all rows from the specified table
| adCmdTableDirect
| 512
| Return all rows from the specified table
| adCmdText
| 1
| Evaluate as a textual definition
| adCmdUnknown
| 8
| The type of the CommandText parameter is unknown
| adCmdUnspecified
| -1
| Default, does not specify how to evaluate
|
ExecuteOptionEnum Constants
Constant
| Value
| Description
| adAsyncExecute
| 0x10
| Execute asynchronously
| adAsyncFetch
| 0x20
| Rows beyond the initial quantity specified should be fetched asynchronously
| adAsyncFetchNonBlocking
| 0x40
| Records are fetched asynchronously with no blocking of additional operations
| adExecuteNoRecords
| 0x80
| Does not return rows and must be combined with adCmdText or adCmdStoredProc
| adOptionUnspecified
| -1
| The option parameter is unspecified
|
EventStatusEnum Constants
Constant
| Value
| Description
| adStatusCancel
| 4
| Cancels the operation that fired the event
| adStatusCantDeny
| 3
| Cannot cancel pending operation
| adStatusErrorsOccurred
| 2
| Indicates that warnings and/or errors occurred
| adStatusOK
| 1
| The operation that fired the event was successful
| adStatusUnwantedEvent
| 5
| The operation that generated the event cannot generate future events
|
|