Executes the specified query, SQL statement, stored procedure, or provider-specific text.
For a non–row-returning command string:
connection.Execute CommandText, RecordsAffected, Options
For a row-returning command string:
Set recordset = connection.Execute (CommandText, RecordsAffected, Options)
Returns a Recordset object reference.
Note Use the ExecuteOptionEnum value adExecuteNoRecords to improve performance by minimizing internal processing.
Do not use the CommandTypeEnum values of adCmdFile or adCmdTableDirect with Execute. These values can only be used as options with the Open and Requery methods of a Recordset.
Using the Execute method on a Connection object executes whatever query you pass to the method in the CommandText argument on the specified connection. If the CommandText argument specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not intended to return results (for example, an SQL UPDATE query) the provider returns Nothing as long as the option adExecuteNoRecords is specified; otherwise Execute returns a closed Recordset.
The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type.
The contents of the CommandText argument are specific to the provider and can be standard SQL syntax or any special command format that the provider supports.
An ExecuteComplete event will be issued when this operation concludes.
Note URLs using the http scheme will automatically invoke the Microsoft OLE DB Provider for Internet Publishing. For more information, see Absolute and Relative URLs.
Visual Basic Example | Visual C++ Example | Visual J++ Example
Execute Method (ADO Command) | ExecuteComplete Event
Applies To: Connection Object