You can pass updated recordsets from client computers to the middle tier and the database server by using:
Data-bound controls enable the user to visually edit, add, or delete records. All changes by the user are stored locally until the user explicitly submits or cancels the update.
Typically, you will bind a grid control to an AdvancedDataControl object, and then add, edit, and delete records to the records in the client-side recordset via the user interface. After you update the client-side data cache, you need to save the changed information to the database by using the SubmitChanges method with the AdvancedDataControl object. The SubmitChanges method submits pending changes of the locally cached updatable Recordset to the ODBC data source specified in the AdvancedDataControl object's Connect property.
The following code example shows how to do this:
Sub Update_OnClick ADC1.SubmitChanges End Sub
Only the changed records are sent for modification, and either all of the changes succeed or all of them fail together.
You can also include a Cancel button to cancel changes to the recordset:
Sub Cancel_OnClick ADC1.CancelUpdate End Sub
Notes
Because users are working with disconnected recordsets on a client-side cache, there may be multiuser issues. You might wonder what happens when two different users try to update the same record. Remote Data Services has a locking mechanism where the user who updates the record first "wins." The second user's update request will fail with an error.
You can use the ADOR.Recordset object to marshal recordsets from a client Web page to a middle-tier business object. For example, suppose a user connects to a virtual shopping mall and selects a number of items to purchase. The selected items appear in the virtual shopping cart that is implemented with the AdvancedDataControl object and buffered in a rowset. When the client clicks the purchase button, an ADOR.Recordset object is created and passed to an application server as an input parameter to a business function (ApplyUpdates). This causes the Recordset to be marshaled across to the server. The ApplyUpdates business function then connects to the Sales database and applies the updates.
' Code on a client Web page. Sub PurchaseItem_OnClick Set rso = adc1.Recordset ' The following option tells the recordset to send ' back changed records only when working with ' updates. ' This makes the roundtrips more lightweight. ' The value of 1 is the same as setting it to ' adMarshalModifiedOnly. rso.MarshalOptions = 1 ' Call the ApplyUpdates function on the bop ' business object and pass the ADOR.Recordset ' object as an input parameter. bop.ApplyUpdates rso End Sub ' Code in the business object. ' ApplyUpdates is a method in a ' middle-tier business object. Sub ApplyUpdates(rso As ADOR.Recordset) Dim rs As New ADODB.Recordset rs.Open sql, _ "DSN=SalesDB;UID=SMgr;PWD=password;", _ adOpenUnspecified, adLockUnspecified, _ adCmdUnspecified ' Call a method on the ADODB.Recordset to save ' updates. rs.UpdateBatch End Sub