Using ADO to Pass Recordset Objects to the Middle Tier

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 RDS.DataControl 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 rst = 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.
   rst.MarshalOptions = 1

   ' Call the ApplyUpdates function on the MyObj
   ' business object and pass the ador.Recordset
   ' object as an input parameter.
   MyObj.ApplyUpdates rst

End Sub


' VB code in the business object.
' ApplyUpdates is a method in a 
' middle-tier business object. 
Sub ApplyUpdates(rst As ADOR.Recordset)

   Dim rs As New ADODB.Recordset

   rs.ActiveConnection =  _
      "DSN=SalesDB;UID=SMgr;PWD=password

   rs.Open rso

   ' Call a method on the ADODB.Recordset to save
   ' updates.
   rs.UpdateBatch

End Sub