Disconnecting Recordsets

Team-Fly

A popular and very powerful feature of ADO is its capability to "dissociate" a Recordset from its parent Connection. Once you break off a Recordset from its Connection, you can pass it to another ADO-aware tier where it can be manipulated at will. You can scroll through the rows, add new ones, and delete and update rows. All of these changes are saved in the Recordset object itself. You can save the Recordset locally using the Save method, as we discussed previously, or send it to another tier for processing.

There are a few requirements that you must satisfy to get the disconnected Recordset to work. You must:

  • Set the Connection object's CursorLocation property to adUseClient. The client-side cursor library implements this functionality.
  • Open the Recordset setting LockType to adLockBatchOptimistic.
  • Assign the ActiveConnection property to Nothing. I used to say "Set" the ActiveConnection property to Nothing, but this is not necessary.

That's it. When you're ready to post the changes to the database, you can reassociate the Recordset with a valid Connection object and use the UpdateBatch method to post the changes.


Team-Fly


ADO Examples and Best Practices
Ado Examples and Best Practices
ISBN: 189311516X
EAN: 2147483647
Year: 2000
Pages: 106

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net