Command Object
A Command object is a definition of a specific command that you intend
to execute against a data source.



Collections
Parameters, Properties
Properties
ActiveConnection, CommandText,
CommandTimeout, CommandType,
Prepared
Methods
CreateParameter, Execute
Remarks
You can create a Command object independently of a previously defined Connection
object by setting its ActiveConnection
property to a valid connection string. ADO still creates a Connection
object, but it doesn't assign that object to an object variable. However,
if you are associating multiple Command objects with the same
connection, you should explicitly create and open a Connection object;
this assigns the Connection object to an object variable. If you do not
set the Command objects' ActiveConnection property to this
object variable, ADO creates a new Connection object for each Command
object, even if you use the same connection string.
Use Command objects to obtain records and create a Recordset
object, to execute a bulk operation, or to manipulate the structure of a
database. Depending on the functionality the provider exposes, some
collections, methods, or properties of a Command object may generate an
error when you call them.
With the collections, methods, and properties of a Command object, you
can do the following:
· Associate an open connection and the Command
object with the ActiveConnection property.
· Define the text version of the command
(for example, an SQL statement) with the CommandText
property.
· Set the number of seconds a provider
will wait for a command to execute with the CommandTimeout
property.
· Specify the type of command described in
the CommandText property with the CommandType
property prior to execution in order to optimize performance.
· Determine whether or not the provider
saves a prepared (or compiled) version of the command prior to execution with
the Prepared property.
· Manage command arguments passed to and
from the provider with the Parameters
collection.
· Execute a command and return a Recordset
object if appropriate with the Execute method.
See Also
Connection
|