ADODB Object
 
Syntax
 
'Syntax for non-row-returning:
commandobject.Execute [RecordsAffected][, Parameters][, Options]
 
'Syntax for row-returning:
Set recordsetobject = commandobject.Execute([RecordsAffected][, Parameters][, Options])
 
Description
Executes the query, SQL statement or stored procedure.
 
Syntax for row-returning:  
The Execute method returns a reference to a Recordset object. You use this method to execute the query, SQL statement, or stored procedure contained in the CommandText property of the Command object. If it is a row-returning query, the results are stored in a new Recordset object. If it is not a row-returning query, the provider will return a closed Recordset object.
 
There are three optional parameters.
 
Parameter
Description
RecordsAffected
The optional RecordsAffected parameter is a long value returned by the provider that is the number of records affected by an action query. (For a row-returning query, you will need to use the RecordCount property of the Recordset object to get a count of how many records are in the object.)
Parameters
The optional Parameters parameter is used to change, update, or insert new parameter values into the Parameters Collection assigned to the Command object.
Options
The optional Options parameter defines how the provider should evaluate the CommandText parameter. It is a long value that is the sum of one or more of the CommandTypeEnum or ExecuteOptionEnum constants. The default is adCmdUnspecified or -1.
 
 
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
51
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 CommandText parameter is unspecified
See Also
Example
 
Set objCommand.Text = "SELECT FirstName, LastName FROM StaffList"
objCommand.Execute
 
 
Set objCommand.Text = "StaffList"
objCommand.Execute( , , adCmdTableDirect)