Step 6: Changes are Sent to the Server (RDS Tutorial)

Microsoft ActiveX Data Objects (ADO)

Step 6: Changes are Sent to the Server (RDS Tutorial)

You are Here...

  • Specify the program to be invoked on the server, and obtain a proxy.

  • Invoke the server program. Pass parameters to the server program that identifies the data source and the command to issue.

  • The server program obtains a Recordset object from the data source, typically by using ADO.

  • The server program returns the final Recordset object to the client application.

  • On the client, the Recordset object is optionally put into a form that can be easily used by visual controls.

  • Changes to the Recordset object are sent back to the server and used to update the data source.

Discussion

If the Recordset object is edited, any changes (that is, rows that are added, changed, or deleted) can be sent back to the server.

Note   The default behavior of RDS can be invoked implicitly with ADO objects and the Microsoft OLE DB Remoting Provider. Queries can return recordsets, and edited recordsets can update the data source. This tutorial doesn't invoke RDS with ADO objects, but this is how it would look if it did:

Dim rs as New ADODB.Recordset
rs.Open "SELECT * FROM Authors", "Provider=MS Remote;Data Source=Pubs;Remote Server=http://YourServer"
...              ' Edit the recordset
rs.UpdateBatch   ' The equivalent of SubmitChanges
...

Part A   Assume for this case that you have only used the RDS.DataControl and that a Recordset object is now associated with the RDS.DataControl. The SubmitChanges method updates the data source with any changes to the Recordset object if the Server and Connect properties are still set.

Sub RDSTutorial6A()
Dim DC as New RDS.DataControl
Dim RS as ADODB.Recordset
DC.Server = "http://yourServer"
DC.Connect = "DSN=Pubs"
DC.SQL = "SELECT * FROM Authors"
DC.Refresh
...
Set RS = DC.Recordset
   ' Edit the Recordset
...
DC.SubmitChanges
...

Part B   Alternatively, you could update the server with the RDSServer.DataFactory object, specifying a connection and a Recordset object.

Sub RDSTutorial6B()
Dim DS As New RDS.DataSpace
Dim RS As ADODB.Recordset
Dim DC As New RDS.DataControl
Dim DF As Object
Dim blnStatus As Boolean
Set DF = DS.CreateObject("RDSServer.DataFactory", "http://yourServer")
Set RS = DF.Query ("DSN=Pubs", "SELECT * FROM Authors")
DC.SourceRecordset = RS    ' Visual controls can now bind to DC.
    ' Edit the Recordset
blnStatus = DF.SubmitChanges "DSN=Pubs", RS
End Sub

This is the end of the tutorial.