Microsoft Office Tutorials and References
In Depth Information
Key Properties and Methods of the Command Object
Table 23-5 lists some of the key properties and methods associated with the Command object.
Table 23-5. Key Properties and Methods of the Command Object
Property: points to an open Connection object
that will be used to execute the command or
that contains a connection string that will be
used to connect to the database.
Property: the command that will be executed
on the database.
Property: specifies the type of command in
CommandText . Can be adCmdText ,
adCmdTable , or adCmdStoredProc .
Direction, Size, Value) As Parameter
Method: creates a Parameter object using the
specified type information.
Options) As Recordset
Method: executes the command and
optionally returns a Recordset object
containing any rows retrieved from the
Property: contains the name of the command.
Property: pointer to a Parameters collection
object containing the parameter values that
will be substituted into the command when
The CommandText property contains the command that you want to execute, whereas the
CommandType property describes the type of command stored in the CommandText prop
erty. There are three basic types of commands you can create: SQL statements, table names,
and stored procedures.
For more information on SQL syntax, see Chapter 22, “Excel and the Structured Query Language”.
The ActiveConnection property contains either an object reference to an open Connection
object, or it contains a connection string that will be used to dynamically create a connection
to the database when the Execute method is called.
The CreateParameter method creates a new Parameter object using the specified information
about the data type. Once you’ve created the new Parameter object, you must add it to the
Parameters collection using the Parameters.Append method.