Execute Method (Connection) ADO

Executes the specified query, SQL statement, or stored procedure.

Applies To

Connection

Required Files

msado15.dll
VC: adoint.h, adoid.h

Syntax

Set recordset = connection.Execute(CommandText, RecordsAffected, Options)

connection.Execute CommandText, RecordsAffected, Options

CommandText A String containing the SQL statement, table name, or stored procedure to execute.
RecordsAffected Optional. A Long variable to which the provider returns the number of records that the operation affected.
Options Optional. A CommandTypeEnum value that indicates how the provider should evaluate the CommandText argument. Can be one of the following constants:
  • adCmdText, 1 — Evaluate CommandText as a textual definition of a command.

  • adCmdTable, 2 — Evaluate CommandText as a table name.

  • adCmdStoredProc, 4 — Evaluate CommandText as a stored procedure.

  • adCmdUnknown, 8 — The type of command in the CommandText argument is not known.
See the CommandType property for a more detailed explanation of these constants.

Remarks

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 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.

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.

Examples

Execute, Requery, Clear Methods Example (VB)

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.