ADO » Connection » Execute

Syntax:
Syntax for non-row-returning:
connectionbject.Execute CommandText, RecordsAffected, Options

Syntax for row-returning:
Set rsobject = connectionbject.Execute (CommandText, RecordsAffected, Options)
CommandText
The mandatory CommandText parameter is a string that contains the specified query, SQL statement, stored procedure, or provider-specific text that you wish to execute.
RecordsAffected
The optional RecordsAffected parameter is a long variable in which the provider stores the number of records that were affected by the query.
Options
The optional Options parameter defines how the provider should evaluate the CommandText parameter. It is a long value that is one or more of the CommandTypeEnum or ExecuteOptionEnum constants. The default is adCmdUnspecified or -1.

Executes the query, SQL statement, stored procedure, or provider-specific text.

The Execute method is used to execute the specified query, SQL statement, stored procedure, or provider-specific text. If it is a row-returning query, the results (if any) will be stored in a new RecordSet object. If it is a non-row-returning query, the provider will return a closed RecordSet object.
 
The default cursor is forward-only and read-only. You can use the CursorType property of the RecordSet object to choose other cursors. If the requested cursor is not available, the provider may choose another cursor.
 
There is one mandatory parameter and two optional parameters.
    
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

Examples

Code:
strCommandText = "SELECT Chants FROM GuruChantsTable"
Set objRecordset = objConnection.Execute(strCommand, ,adCmdText)

...

See Also: