Disconnected Recordsets

ne of the great and flexible features of the amazing elastic ADO recordset is that it can be disconnected from its data source, modified, and reconnected to update the data source. Once disconnected, it can be saved to disk or inserted into an email, and sent to another user. The second user can make changes and send it back to the first user, who can then open it from disk and update the data source. Here are the step-by-step instructions:

1. Open a client side recordset in UpdateBatch mode:

Dim rs as New ADODB.Recordsetrs.CursorLocation=adUseClientrs.LockType= adLockBatchOptimisticrs.Open Source:="Select * From Authors", ActiveConnection:="Pubs" 'Pubs is an ODBC DSN 

2. Disconnect the recordset by setting its ActiveConnection to Nothing. Don’t close the connection. When a connection is closed it closes all associated recordsets.

Set rs.ActiveConnection = Nothing

3. Modify the data. Even though the recordset is disconnected from its data source, it is still fully functional. You can make changes to the data and save it using the Update method. All changes are stored in the recordset until the UpdateBatch method is called. The quickest way to display and modify the data is to place an instance of the Microsoft DataGrid 6.0 OLEDB (MSDATGRD.OCX) on a form and set its DataSource property to the recordset.

Set DataGrid1.DataSource=rs

4. Save the recordset to disk. Use the recordset’s Save method. You can save it with any extension, I prefer .rs:

rs.Save "D:Authors.rs"

5. Send the recordset file to another user via floppy disk or email. She can open it using the recordset’s Open method with adCmdFile for the Options argument:

rs.Open Source:="D: Authors.rs", Options:=adCmdFile

6. The second user can modify the data and save changes back to the persisted file from which the recordset was opened by calling the recordset’s Save method without specifying a filename.

rs.Save

7. The second user can send it back to the first user who can reconnect the recordset by setting it to a valid connection. If the recordset is already open then close it using the Close Method.

On Error Resume Nextrs.CloseOn Error Goto 0rs.ActiveConnection = "Pubs"

8. To update the data source with all the changes call the recordset’s Updatebatch method.

rs.UpdateBatch
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.