Using the Save method, a recordset's contents can be saved to a file. This process is called persisting data. This is particularly useful if the user wishes to close the application and return to it later without reconnecting to the data source.

Persisting data is also useful for a disconnected recordset, since the connection and the application can be closed while the recordset is still available on the client computer.

Saving Data to a File

To save the contents of the current recordset to a file, use the Save method. The Save method allows you to specify the format of the data and whether an existing file should be overwritten. By default, the Save method fails if a file with the same name already exists.


Note  If a filter is currently active, only the records that are visible through the filter will be saved to the file.

The following example code saves the recordset's contents to a file on the local computer:

rsStudents.Save "c:\studentinfo.dat", adPersistADTG
  


Note  Once a recordset has been saved, it is static. Any additional changes made to the recordset after calling the Save method will not be reflected in the persisted data when it is retrieved.

Retrieving Persisted Data

To rebuild the recordset from data that was saved, use the Open method and refer to the file name. The following example code reopens a persisted recordset:

rsStudents.Open "c:\studentinfo.dat"