The ActiveX Data Object (ADO) module enables programs written in C++ and Visual Basic to connect to different databases and SQL servers. It includes several objects, such as the ADO command object. This object executes a single query against the database. We can create, add, update, delete, and retrieve records with the help of this query.
If we retrieve the data using a query, the returned data is in the form of a Recordset object. We can then manipulate the data by using the properties, collections, methods, and events of the Recordset object.
A major feature of the command object is the ability to use procedures with parameters and stored queries.
The command object has certain methods, properties, and collections associated with it. These are described below.
Execute
: This executes the query or SQL statement or procedure in CommandText property, returning a Recordset object or Nothing.
Cancel
: This cancels the execution of an asynchronous method call.
CreateParameter
: This creates a new parameter object.
Name
: This sets or returns the name of a command object.
State
: This returns the current state of a command object and is a read-only property.
Prepared
: This sets or returns a Boolean value. If the value is true
, it indicates that before executing the first command. The command saves a compiled version of the query.
CommandType
: This sets or returns the type of a Command object, a value from CommandTypeEnum
.
CommandTimeout
: This sets or returns the number of seconds to wait before terminating an execution attempt before raising an error.
ActiveConnection
: This sets or returns a message if the connection is closed. Otherwise, if the connection is open, it returns the current connection object. It tells us which Connection object is associated with the current Command object.
CommandText
: This sets or returns the text of a Command object’s command.
Properties
: This contains all the property objects of a Command object.
Parameters
: This contains all the parameter objects of a Command object.
Free Resources