Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

ADO Command Object

The Command object defines a specific command to execute against a data source.

ADO Command Object Collections

ADO Parameters Collection

Contains all the Parameter objects of a Command object.

ADO Properties Collection

Contains all the Property objects for a specific instance of a Command object. This collection is not currently supported on UNIX.

ADO Command Object Methods

ADO Command Object CreateParameter Method

Creates a new Parameter object with the specified properties.

ADO Command Object Execute Method

Executes the query, SQL statement, or stored procedure specified in the CommandText property.

ADO Command Object Properties

ADO Command Object ActiveConnection Property

The Connection object to which the specified Command object currently belongs.

ADO Command Object CommandText Property

The text of a command that you want to issue against a provider.

ADO Command Object CommandTimeout Property

How long to wait while executing a command before terminating the command and issuing an error.

ADO Command Object CommandType Property

The type of Command object.

ADO Command Object Name Property

The name of a specific Command object. This property is not currently supported on UNIX

ADO Command Object Prepared Property

Whether or not to save a compiled version of a command before execution. This property is not currently supported on UNIX.

ADO Command Object State Property

The current state of the Command object. This property is not currently supported on UNIX

ADO Command Object Remarks

A Command object is used to query a database, return records in a ADO Recordset Object, execute bulk operations, or manipulate the structure of a database. It is a definition of a specific command that you intend to execute against a data source.

The collections, methods, and properties of a Command object are used to:

   Define the executable text of the command (for example, an SQL statement) with the ADO Command Object CommandText Property.

   Define parameterized queries or stored procedure arguments with ADO Parameter Object objects and the ADO Parameters Collection.

   Execute a command and return a ADO Recordset Object if appropriate with the ADO Command Object Execute Method.

   Specify the type of command with the ADO Command Object CommandType Property prior to execution to optimize performance.

   Set the number of seconds a provider will wait for a command to execute with the CommandTimeout property.

   Associate an open connection with a Command object by setting its property.

   Set the ADO Command Object Name Property to identify the Command object as a method on the associated ADO Connection Object.

   Pass a Command object to the ADO Recordset Object Source Property of an ADO Recordset Object in order to obtain data.

To execute a query without using a Command object, pass a query string to the ADO Connection Object Execute Method of an ADO Connection Object or to the ADO Recordset Object Open Method of an ADO Recordset Object. However, a Command object is required when you want to retain the command text and re-execute it, or use query parameters.

To create a Command object independently of a previously defined Connection object, set 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 object's ActiveConnection property to this object variable, ADO creates a new Connection object for each Command object, even if you use the same connection string.

To execute a Command, simply call it by its ADO Command Object Name Property on the associated Connection object. The Command must have its ActiveConnection property set to the Connection object. If the Command has parameters, pass values for them as arguments to the method.

Depending on the functionality of the provider, some Command collections, methods, or properties may generate an error when referenced.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.