Persisting Your Data

[Previous] [Next]

A salesman walks into a psychiatrist's office and says, "Doc, you have to help me!" No, wait, that's not it….

A salesman walks into the MIS director's office and says, "Fred, you have to help me! The order entry system is wonderful, but I need you to modify it slightly so that I can load it onto my laptop. I want to enter new customers and orders while I'm out on the road, save them on my hard drive, and load them into the database when I'm done playing golf…I mean when I'm back in the office."

Those clever programmers on the ADO team thought of this exact scenario (even though programmers, by trade, tend not to get along with salespeople). You can save a client-side Recordset to a file and reopen it at a later time, as shown in the following code snippet. If you choose, you can even send that persisted recordset as an e-mail attachment and have another user or application open it.

 strSQL = "SELECT CustomerID, CustomerName, BalanceDue FROM Customers" rsCustomers.CursorLocation = adUseClient rsCustomers.Open strSQL, cnDatabase, adOpenStatic, adLockBatchOptimistic Set rsCustomers.ActiveConnection = Nothing cnDatabase.Close rsCustomers.Save strPathToFile  cnDatabase.Open rsCustomers.Open strPathToFile, Options:=adCmdFile Set rsCustomers.ActiveConnection = cnDatabase rsCustomers.UpdateBatch 

In Chapter 13, we'll talk more about how to use persisted recordsets, what data is saved, and the different formats you can use to save your data.



Programming ADO
Programming MicrosoftВ® ADO.NET 2.0 Core Reference
ISBN: B002ECEFQM
EAN: N/A
Year: 2000
Pages: 131
Authors: David Sceppa

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