Using disconnected recordsets, ADO allows your application to create a recordset, disconnect from the data source, and let the user view and edit the recordset offline. When the user has made the desired changes, your application can reconnect to the data source and update the database.

To support a disconnected recordset, you must specify that the recordset will be built on the client.

Creating a Client-Side Recordset

To specify that the recordset should be built on the client, use the adUseClient parameter with the Recordset object's Open method.

To see sample code that creates a new recordset that will be built on the client, click on the icon below.

Disconnecting from the Data Source

Setting the recordset's ActiveConnection property to Nothing disconnects the recordset from the active connection. Your application can then close the active Connection object using the Close method. If the adUseClient parameter was used with the Open method, the client will have a copy of the recordset data and can begin navigating or updating the records. The following example code closes the connection and disconnects from the data source:

Set rsStudents.ActiveConnection = Nothing
cnStateUBookstore.Close
  

Making Offline Changes

Once a recordset has been disconnected from the data source, your application can use any of the data update and navigation techniques. For more information, see Retrieving Data from a Data Source in this chapter. New records can be added using the AddNew method, records can be deleted using the Delete method, and existing records can be changed using the Update method. However, all changes are cached on the client until the connection is re-established.


Note  Offline changes made to the same record by more than one user will cause a conflict when the data is saved back to the data source.