VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Persistent Recordsets - Visual Basic 6 (VB6)

A persistent Recordset is a Recordset (typically a dynamic or disconnected Recordset as discussed in the previous two sections) whose information you save between sessions of your application into a local "holding file."

To implement a persistent Recordset, you call a Recordset object's Save method to save it to a file. When you want the saved data back, you call a Recordset object's Open method with an argument that indicates the name of the file where you previously saved Recordset data.

You need to take the following steps in your code to implement a persistent Recordset object:

  1. Make sure you have an open Recordset object with which to work.

  2. Call the Recordset object's Save method with two arguments:

    • The first argument represents the name of the file where you will save the Recordset object's data.

    • The second argument represents the data format that you will use to save data to the file. As of this writing, there's only one possible value for this argument, adPersistADTG.

  3. When you want to retrieve previously saved information from a file into a Recordset, call the Recordset's Open method, passing to the Open method as its first and only argument the name of the file where you previously saved the Recordset information.

Listing 8.15 gives an example of code that implements a persistent disconnected Recordset.


'Assumes that rs has been
'previously declared and initialized
Private Sub cmdSaveDisconn_Click()
If Dir$("C:\trash\mydata.dat") <> "" Then
Kill "C:\trash\mydata.dat"
End If
rs.Save "C:\Trash\MyData.dat", adPersistADTG
End Sub
Private Sub cmdRetrieveDisconn_Click()
Set rs = Nothing
Set rs = New ADODB.Recordset
rs.Open "C:\Trash\MyData.dat"
End Sub

See Also


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved