Recordset Persistence

Microsoft ActiveX Data Objects (ADO)

Recordset Persistence

The Microsoft OLE DB Persistence Provider supports storing a Recordset object in a file with the Recordset object's Save method. The persistently stored file may exist on a local drive, network server, or as a URL on a Web site. Later, the file can be restored with either the Recordset object's Open method, or the Connection object's Execute method.

In addition, the GetString method converts a Recordset object to a form in which the columns and rows are delimited with characters you specify.

To persist a Recordset, begin by converting it to a form that can be stored in a file. Recordset objects can be stored in the proprietary Advanced Data TableGram (ADTG) format, or the open Extensible Markup Language (XML) format.

Note   Two limitations apply when saving hierarchical Recordsets (data shapes) to XML format. You cannot save to XML if the hierarchical Recordset contains pending updates, and you cannot save a parameterized hierarchical Recordset.

Then, save any pending changes in the persisted file. Doing this allows you to issue a query that returns a Recordset object; edits the recordset; saves it and the pending changes; later, restores the recordset; then updates the data source with the saved pending changes.

For information about persistently storing Stream objects, see Streams and Persistence.

For an example of Recordset persistence, see the XML Recordset Persistence Scenario.

Example

Save a Recordset:

Dim rs as New ADODB.Recordset
rs.Save "c:\yourFile.adtg", adPersistADTG

Open a persisted file with Recordset.Open:

Dim rs as New ADODB.Recordset
rs.Open "c:\yourFile.adtg", "Provider=MSPersist",,,adCmdFile

Optionally, if the Recordset does not have an active connection, you can accept all the defaults and simply code the following:

Dim rs as New ADODB.Recordset
rs.Open "c:\yourFile.adtg"

Open a persisted file with Connection.Execute:

Dim conn as New ADODB.Connection
Dim rs as ADODB.Recordset
conn.Open "Provider=MSPersist"
Set rs = conn.execute("c:\yourFile.adtg")

Open a persisted file with RDS.DataControl:

In this case, the Server property is not set.

Dim dc as New RDS.DataControl
dc.Connection = "Provider=MSPersist"
dc.SQL = "c:\yourFile.adtg"
dc.Refresh