Page 514 - Microsoft Office Excel 2003 Programming Inside Out
P. 514

Microsoft Office Excel 2003 Programming Inside Out

                    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/Method                     Description
                             ActiveConnection	                   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.
                             CommandText	                        Property: the command that will be executed
                                                                 on the database.
                             CommandType	                        Property: specifies the type of command in
                                                                 CommandText. Can be adCmdText,
                                                                 adCmdTable, or adCmdStoredProc.
                             CreateParameter(Name, Type,         Method: creates a Parameter object using the
                             Direction, Size, Value) As Parameter   specified type information.
                             Execute(RecordsAffected, Parameters,   Method: executes the command and
                             Options) As Recordset               optionally returns a Recordset object
                                                                 containing any rows retrieved from the
                                                                 database.
                             Name                                Property: contains the name of the command.
                             Parameters	                         Property: pointer to a Parameters collection
                                                                 object containing the parameter values that
                                                                 will be substituted into the command when
                                                                 it’s executed.

                             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”.
             Chapter 23
                             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.





                488
             Part 6:  Excel and the Outside World: Collaborating Made Easy
   509   510   511   512   513   514   515   516   517   518   519