Microsoft Office Tutorials and References
In Depth Information
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
Method: closes the connection to the database.
Property: defines how to connect to the database.
Property: specifies where the current record pointer is
maintained. Can be: adUseClient or adUseServer .
Property: pointer to an Errors collection object containing the
list of individual Error objects that describe the most recent
error encountered on the connection.
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
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
The Mode property determines what level of data access you require. Specifying adModeRead
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
database (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.