Execute method (ADO connection)
Execute the specified query, SQL statement, stored procedure, or provider-specific text.
Syntax
For command strings not returned by the line:
ConneCtion. Execute comMandtext, recordsaffected, options
For command strings returned in line:
Set recordset = ConneCtion. Execute (CoMmandtext, recordsaffected, options)
Return Value
Returns a recordset object reference.
Parameters
Commandtext string value, including the SQL statement, table name, stored procedure, URL, or provider-specific text to be executed.
Recordsaffected is optional. Long variable, the number of records affected by the operation returned by the provider.
Options is optional. Long value indicates how the provider calculates the commandtext parameter. It can be one or more commandtypeenum or executeoptionenum values.
Description
You can use the execute method of the connection object to execute the query passed to the method in the commandtext parameter of the specified connection. If the commandtext parameter specifies the query returned by rows, any results generated by execution will be stored in the new recordset object. If this command is not a query returned by a row, the provider returns the closed recordset object.
The returned recordset object is always a read-only, forward-only cursor. If you need more recordset objects, you should first create a recordset object with the required attribute settings, then use the open method of the recordset object to perform the query and return the required cursor type.
The content of the commandtext parameter is unique to the provider. It can be a standard SQL syntax or any special command format supported by the provider.
The executecomplete event will be triggered at the end of this operation.
Refer:
Commandtimeout attribute
Indicates the time to wait before terminating the attempt and generating errors during command execution.
Set and return values
Sets or returns a long value, which indicates the number of seconds to wait for command execution. The default value is 30.
Description
Use the commandtimeout attribute of the connection object or command object to cancel the execute method call because of network congestion or delay caused by heavy server load. If the command is not executed within the time interval set by the commandtimeout attribute, an error is generated and ADO cancels the command. If the attribute is set to zero, ADO waits until the command execution is complete. Make sure that the provider and data source for which code is being written support the commandtimeout function.
The commandtimeout setting of the connection object does not affect the commandtimeout setting of the command object in the same connection. That is, the commandtimeout attribute of the command object does not inherit the commandtimeout value of the connection object.
On the connection object, after the connection is enabled, the commandtimeout attribute is read/write.