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

See Also   

You are Here...

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 MS Remote 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 New ADODB.Recordset   'Optionally, ADOR.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 New ADODB.Recordset   'Optionally, ADOR.Recordset
Dim DC as New RDS.DataControl
Dim DF as Object
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

This is the end of the tutorial.