|
|
|
To see the actual code for the ADO disconnected recordset Mailing List Demo, click here to download the zip file (36K) containing the entire demo project.
|
| Here is the scenario:
This is the perfect situation for a disconnected recordset.
|
|
Here is what happens:
|
Specifically the code for 1 through 3 above is:
Dim strFilespec As String
Dim strConn As String
Dim cnContacts As ADODB.Connection
Dim rsContacts As ADODB.Recordset
Set cnContacts = New ADODB.Connection
Set rsContacts = New ADODB.Recordset
strFilespec = App.Path & "\" & "Contacts.mdb"
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strFilespec & ";"
cnContacts.CursorLocation = adUseClient
cnContacts.Open strConn
rsContacts.Open "SELECT * FROM MailList ORDER BY ContactName", _
cnContacts, adOpenStatic, adLockBatchOptimistic, adCmdText
Set rsContacts.ActiveConnection = Nothing
cnContacts.Close
|
Then as you are working with your disconnected recordset, you just update any edits or addnews as usual with:
rsContacts.Update
|
And when you are ready for steps 5 through 7:
cnContacts.Open
Set rsContacts.ActiveConnection = cnContacts
rsContacts.UpdateBatch
rsContacts.Requery
Set rsContacts.ActiveConnection = Nothing
cnContacts.Close
|