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

Microsoft Office Excel 2003 Programming Inside Out

                             Table 23-8.  Key Properties and Methods of the Recordset Object   (continued)
                             Property/Method     Description
                             MoveNext	           Method: moves the current record pointer to the next row in the
                                                 recordset.
                             MovePrevious	       Method: moves the current record pointer to the previous row in
                                                 the recordset.
                             Open                Method: gains access to the data in the Recordset.
                             RecordCount	        Property: contains the total number of rows retrieved from the
                                                 database.
                             Sort	               Property: contains the list of column names on which the results
                                                 should be sorted.
                             Source	             Property: contains either an object reference to a Command object
                                                 or a string with an SQL statement.
                             Update	             Method: saves any changes you might have made to the current
                                                 row to the database.

                             The ActiveConnection property points either to the Connection object associated with Recordset,
                             or it contains a connection string value. If the property contains a connection string, a con­
                             nection to the database will be automatically opened when the Recordset object is opened.
                             The Source property contains either an object reference to a Command object or a string con­
                             taining the name of a table, a stored procedure or an SQL statement. If you assign a Command
                             object to the source property, reading the source property will return the CommandText
                             value from the Command object rather than an object reference.
                             Once you’ve set up all the information that you need to retrieve data from the database, use
                             the Open method to gain access to the information in the Recordset object. When you are
                             through with the data, use the Close method to release all the resources associated with the
                             Recordset object.
                             The Recordset object exposes the returned records from the database one row at a time.
                             Internally, the Recordset object maintains a pointer referred to as the current record pointer,
                             which points to the current record.
                             Because only one record is available at a time, you must use the move methods (MoveFirst,
                             MovePrevious, MoveNext, and MoveLast) to navigate your way through the records in the
             Chapter 23
                             Recordset. The Move method allows you to jump forward or backward in the record the
                             specified number of rows.
                             As you move through the records in the Recordset, the BOF and EOF properties will automat­
                             ically be set as the current record pointer changes. BOF stands for Beginning Of File, and
                             EOF stands for End Of File. The best way to think of these two properties is that they
                             represent locations before the first row in the Recordset (BOF) and after the last row in the
                             Recordset (EOF).



                492
             Part 6:  Excel and the Outside World: Collaborating Made Easy
   513   514   515   516   517   518   519   520   521   522   523