Recordset Persistence

   

With recordset persistence, you can save Recordset data and metadata as a file. Later, use the persisted file to re-create the Recordset object. The persisted file may exist on a local drive, network server, or as a URL on a Web site.

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

Details

The MSPersist provider supports storing a Recordset object in a file with the Recordset object Save method. Later, the persisted file can be restored with either the Recordset object Open, or Connection object Execute methods.

The Recordset object is converted to a string so it can be stored in a file. Currently, the only supported string format is the Microsoft proprietary Advanced Data TableGram (ADTG) format. The MSPersist provider adds a string-valued property, named PersistFormat, to the Recordset object's Properties collection so you can get or set the string format. The default value of PersistFormat is adPersistADTG.

Pending changes are saved in the persisted file. Therefore, you can issue a query that returns a Recordset object; edit the recordset; save it and the pending changes; later, restore the recordset; then update the data source with the saved pending changes.

Usage

Get the current string format:

Dim strFormat as String
strFormat = rs.Properties("PersistFormat")

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",,,adCommandFile

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

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 New 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