Executes the query, SQL statement, or stored procedure specified in the CommandText property.
For a Recordset-returning Command:
Set recordset = command.Execute( RecordsAffected, Parameters, Options )
For a non–recordset-returning Command:
command.Execute RecordsAffected, Parameters, Options
Returns a Recordset object reference or Nothing.
Using the Execute method on a Command object executes the query specified in the CommandText property of the object. If the CommandText property specifies a row-returning query, any results that the execution generates are stored in a new Recordset object. If the command is not a row-returning query, the provider returns a closed Recordset object. Some application languages allow you to ignore this return value if no Recordset is desired.
If the query has parameters, the current values for the Command
object's parameters are used unless you override these with parameter values
passed with the Execute call. You can override a subset of the
parameters by omitting new values for some of the parameters when calling the Execute
method. The order in which you specify the parameters is the same order in
which the method passes them. For example, if there were four (or more)
parameters and you wanted to pass new values for only the first and fourth
parameters, you would pass Array(var1,,,var4)
as the Parameters
argument.
Note Output parameters will not return correct values when passed in the Parameters argument.
An ExecuteComplete event will be issued when this operation concludes.
Visual Basic Example | VBScript Example | Visual C++ Example | Visual J++ Example | CommandText Property | CommandTypeEnum | Execute Method (ADO Connection) | ExecuteComplete Event
Applies To: Command Object