Disconnected Recordsets

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.


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.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several