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

Microsoft Office Excel 2003 Programming Inside Out

                    Key Properties and Methods of the Connection Object
                             Table 23-1 lists some of the key properties and methods associated with the Connection object.

                             Table 23-1.  Key Properties and Methods of the Connection Object
                             Property/Method         Description
                             Close                   Method: closes the connection to the database.
                             ConnectionString        Property: defines how to connect to the database.
                             CursorLocation	         Property: specifies where the current record pointer is
                                                     maintained. Can be: adUseClient or adUseServer.
                             Errors	                 Property: pointer to an Errors collection object containing the
                                                     list of individual Error objects that describe the most recent
                                                     error encountered on the connection.
                             Mode	                   Property: determines how the database is opened. Can be
                                                     adModeRead, adModeWrite, adModeReadWrite,
                                                     adModeShareDenyRead, adModeShareDenyWrite,
                                                     adModeShareExclusive, or adModeShareDenyNone.
                             Open ConnectionString,   Method: establishes a connection to the database using the
                             UserId, Password	       optionally supplied ConnectionString, UserId, and Password
                                                     values.
                             State	                  Property: describes the state of the connection. Can be
                                                     adStateClosed or adStateOpen.

                             The Open method opens a connection to the database using the optional information. If not
                             supplied, the information from the ConnectionString property will be used. The Close
                             method terminates an open connection to the database server. The State property allows you
                             to determine if the connection is open or closed to the database.

                             The CursorLocation property determines where the cursor is kept. Typically, you’ll set this
                             property to adUseServer to simplify the programming involved, especially if you’re using
                             Access. However, if you’re using SQL Server, Oracle, DB2, or some other shared database
                             server, you might want to check with your database administrator to determine what value
                             is appropriate.
                             The Mode property determines what level of data access you require. Specifying adModeRead
             Chapter 23
                             means that your program only reads data from the database and that your program can coex­
                             ist with other applications that specified adModeRead. If you plan only to write to the data-
                             base (which isn’t very common), you can use the adModeWrite value. However, if you plan to
                             read and write information from the database, you should choose the adModeReadWrite value.
                             The adModeShareDenyRead, adModeShareDenyWrite, and adModeShareExclusive properties
                             all control how other programs will share the database with yours. In general, if you have
                             multiple users sharing the same database, see your database administrator for the appropri­
                             ate values for the Mode property.


                484
             Part 6:  Excel and the Outside World: Collaborating Made Easy
   505   506   507   508   509   510   511   512   513   514   515