Command Object

The Command object allows you to manipulate database commands. Although you can execute a command string on a Connection object or as part of opening a Recordset object, the Command object allows you more flexibility. Chief among its extended functionalities is the ability to add, remove, and define query parameters using the Command object's Parameters collection. You can define the text of a database command, such as a SQL statement, using the CommandText property of the Command object. Table 12.2 lists the Command object's properties, Table 12.3 lists its Collection object, and Table 12.4 lists its methods.

Table 12.2. Command Object Properties

Property

Description

ActiveConnection[1]

The name of the Connection object to which the Command object belongs.

CommandText[1]

A string containing the text of the command you wish to execute against the database. It can be a query, SQL statement, the name of a stored procedure, or some other database manipulation command.

CommandTimeout[1]

A Long representing the number of seconds ADO should wait for the results of a Command object's execution before raising an error. The default value is 30 seconds.

CommandType[1]

The type of command that is executed using the Command object.

Name

A string representing the name of the Command object.

Prepared

A Boolean value that, if True, indicates the underlying data provider is instructed to store a compiled version of the command before executing it.

State ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.