ADO Execute Method

Definition and Usage

The Execute method can execute a specified query, SQL statement, stored procedure, or provider-specific text.

If the CommandText parameter specifies a query that returns rows, any results generated will be stored in a new Recordset object. If this command is not a query that returns rows, the provider will return a closed Recordset object.

Note:The returned Recordset object is always a read-only, forward-only cursor.

Tip:If you need a Recordset object with more features, you should first create the Recordset object, set the required properties, and then execute the query and return the required cursor type using the Open method of the Recordset object.

Syntax: For command strings that return rows:

Set objrs = objconn.Execute(commandtext, ra, options)

Syntax: For command strings that do not return rows:

objconn.Execute commandtext, ra, options
Parameters Description
commandtext Required. The SQL statement, table name, stored procedure, URL, or provider-specific text to be executed.
ra Optional. The number of records affected by the query.
options Optional. Set how the provider should set the calculation of the commandtext parameter. It can be one or more CommandTypeEnum Or ExecuteOptionEnum Value. The default is adCmdUnspecified.

Example

<%
sql = "SELECT companyname FROM Customers"
Set rs = conn.Execute(sql)
%>