Saving a Recordset to Disk

The ADO has a Save method that allows you to save a recordset to disk and work with it from your VBA application. This method takes two parameters. You must specify a filename and one of the following two data formats:

■ adPersistADTG — Advanced Data TableGram

■ adPersistXML — Extensible Markup Language

A saved (orpersisted) recordset is a recordset that is saved to a file. This file can later be reopened without an active connection.

In this section, you will persist a recordset into a file using the adPersistADTG format. You will work with the adPersistXML format in Part V of this book.

To save a recordset in a file, you must first open it. When you have applied a filter to a recordset and then decide to save this recordset, only the filtered records will be saved. Using the Save method does not close the recordset. You can continue to work with the recordset after it has been saved. However, always remember to close the recordset when you are done working with it.

The procedure in Hands-On 16-3 opens the recordset based on the Customers table. Once the recordset is open, the Save method is called to persist the customer records into a file.

0 0

Post a comment