In ADO 2.0, the ADO development team added a Save method to the Recordset object so that you could write code that looks like this:
strSQL = "SELECT * FROM Orders" rsOrders.CursorLocation = adUseClient rsOrders.Open strSQL, cnDatabase, adOpenStatic, _ adLockBatchOptimistic, adCmdText 'Disconnect from the database. Set rsOrders.ActiveConnection = Nothing 'Modify the data. 'Save the modifications and close the Recordset. rsOrders.Save strPathToFile, adPersistADTG rsOrders.Close 'At this point the user closes and reopens the application. 'Open the Recordset, reset the connection, and update the database. rsOrders.Open strPathToFile, , adOpenStatic, _ adLockBatchOptimistic, adCmdFile Set rsOrders.ActiveConnection = cnDatabase rsOrders.UpdateBatch |
This code performs the following actions:
Of course, you'd want to create separate code modules to group specific actions, but I think you get the idea: ADO saves you time by simplifying this potentially complex scenario.
In ADO 2.1, they added a second format for the data: eXtensible Markup Language (XML). Simply use the optional PersistFormat parameter on the Save method to store your data in XML format, as shown here:
rsOrders.Save strPathToFile, adPersistXML |
Now how much would you pay? Don't answer yet. Just look what else you get! ADO 2.5 brings even more functionality to the Save method. No longer do you need to store your data in a file; you can now save the data in a stream. You can use the Save method with the new ADO Stream object or with the Response object, which is available through the Active Server Pages (ASP) object model. Implementation examples using the Stream and Response objects, respectively, are shown here:
'Use the ADO Stream object with the Save method. Set stmData = New ADODB.Stream rsOrders.Save stmData, adPersistADTG 'Use the ASP Response object with the Save method. rsOrders.Save Response, adPersistADTG |