Microsoft Office 2000/Visual Basic Programmer's Guide |
The Jet 4.0 database engine provides a new feature called connection control, which prevents users from connecting to a database. This feature is also called passive shutdown because when connection control is invoked, users who are currently connected to the database remain unaffected until they disconnect. This capability is useful if you need to acquire exclusive access to a database to perform maintenance operations, such as compacting the database, or make updates to the database's design.
When connection control is invoked, users who are currently connected to a database remain unaffected until they disconnect from the database. At that point they will be unable to reconnect to the database until the user who invoked connection control revokes it or closes his or her connection to the database.
The following scenarios provide examples of how the connection control feature works. Assume there are five users in the database and that user five has invoked connection control on the database:
To use connection control, set the Jet OLEDB:Connection Control provider-specific property on an ADO Connection object. The Jet OLEDB:Connection Control property is a Long value that can be set to 1 to invoke connection control, or to 2 (the default value) to revoke connection control. The following procedure either invokes or revokes connection control for the current Access database, based on the value of the opgConnectionControl enumeration, which can be either INVOKE_CONTROL (which equals 1) or REVOKE_CONTROL (which equals 2).
Sub ConnectionControl(lngState As opgConnectionControl)
CurrentProject.Connection. _
Properties("Jet OLEDB:Connection Control") = lngState
End Sub
The ConnectionControl procedure can be found in the MultiuserIssues module of the MultiuserDatabase.mdb sample file, which is available in the ODETools\V9\Samples\OPG\Samples\CH16 subfolder on the Office 2000 Developer CD-ROM.