Chapter 11 -- Update Resync

[Previous] [Next]

Chapter 11

Let's briefly recap how the ADO Cursor Engine performs updates. When you write code such as the following

 strSQL = "SELECT CustomerID, CustomerName, BalanceDue " & _ "FROM Customers" With rsCustomers .CursorLocation = adUseClient .Open strSQL, cnDatabase, adOpenStatic, _ adLockOptimistic, adCmdText .Fields("BalanceDue") = 150 .Update End With 

ADO executes an action query that modifies the data in your database based on the changes you've made to your Recordset. In this case, the action query looks like this:

 UPDATE Customers SET BalanceDue = 150 WHERE CustomerID = 7 AND BalanceDue = 100 

To determine whether the query succeeded in updating the appropriate data, ADO examines the number of records affected by the action query. If at least one record was affected, ADO interprets this as a successful update. If no records were updated, ADO interprets this as a failed update because of a change made by another user. That record might have been deleted, or the value of the BalanceDue field might have changed. Such is the nature of optimistic updating.

You'll sometimes need more than just an action query, however. In some situations you'll want to retrieve data immediately after submitting a change to the database.



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