INFO: Techniques for Returning a Recordset via RDS

ID: Q183294


The information in this article applies to:


SUMMARY

There are three techniques for returning data in a disconnected recordset using the Remote Data Service (RDS). There are two objects on the client, the RDS.DataControl and RDS.DataSpace, and one object on a server, RDSServer.DataFactory, which you can manipulate in different ways to generate a recordset, and to submit changes made to the data it contains. The correct method for your application depends upon the design and functionality you want.


MORE INFORMATION

The Remote Data Service allows you to remote an ActiveX Data Objects (ADO) Recordset across HTTP, HTTPS or DCOM to a client computer. If using the HTTP/HTTPS protocal it assumes that you have a server running either Internet Information Server 3.0 (or greater), or Personal Web Server. In either case, you will have installed the RDS Server components on that server. The client computer requires the RDS 1.1, 1.5 or RDS 2.0 components, and the client application can be written in any language that supports COM and manipulation of COM Objects (C++, Java, Visual Basic For Applications, VBScript, and so forth).

There are two types of ADO Recordsets that you see used in conjunction with RDS. The ADODB recordset comes from Msado15.dll, and is part of the entire ADO object hierarchy. However, when marshalling a recordset across the wire, in order to provide a thin client, (minimal DLL's and memory footprint), RDS converts that recordset into an ADOR recordset. ADOR (from Msado15r.dll) comes without the rest of the ADO object model. For the purposes of this discussion (as well as any code you write) ADOR.Recordset and ADODB.Recordset are synonymous. You should reference ADOR.Recordset in your client application and whether you use ADOR.Recordset or ADODB.Recordset in your server-side custom business object is irrelevant. However, if you use ADODB, you can use the Connection and Command objects which offer functionality not available just opening a recordset "stand- alone".

Technique #1 - The DataControl


You can use the RDS.DataControl to retrieve a recordset from the RDS Server via the Refresh method. You could also assign an existing recordset to the SourceRecordset property.

Within the Active Server Pages page (ASP) environment, you can bind graphical controls to the RDS.DataControl. Internet Explorer 3.02 supported approximately a dozen specific controls, but with Internet Explorer 4.0, this number was reduced.

Whether in ASP or any other development environment, you can easily use the RDS.DataControl programmatically to retrieve, sort, and filter data. Most of the properties and methods of the DataControl resemble a subset of the ADO Recordset (either ADOR or ADODB.) The RDS.DataControl also offers asynchronous processing that is currently not offered within ADO 1.5. With the release of ADO 2.0 asynchronous processing is available.

The RDS.DataControl uses a business object on the server, provided by RDS, called the RDSServer.DataFactory. The DataFactory generates a recordset and also receives changes made to the data it contains. You cannot override (directly) the DataControl to use a different business object.

The following code demonstrates this technique using Visual Basic for Applications (VBA):



  Dim dc As RDS.DataControl

   Set dc = New RDS.DataControl
   ' ASP Set dc = CreateObject("rds.datacontrol")
   dc.Connect = "DSN=RDSDemo;UID=admin;PWD=;"
   dc.SQL = "SELECT * FROM Authors"
   dc.Server = "http://<Server Name>"
   dc.ExecuteOptions = adcExecAsync  'RDS 1.5 Client Only!
   dc.Refresh
   While dc.ReadyState = 2  ' RDS 1.5 Client Only!
      DoEvents             ' User has control during asynchronous query.
   Wend
 

Technique #2 - Using the DataSpace with the Default Business Object


You may use the RDS.Dataspace object to invoke a business object on the server. If you provide the ProgID of the default business object (RDSServer.DataFactory), then you use the business object RDS provides for you. This business object can provide a Recorsdet, but offers no conflict resolution (or any information) regarding a failure if the changes you post to the data are not accepted.

The following code demonstrates this technique using VBA:



   Dim ds
   Dim df
   dim rs

   Set ds = CreateObject("RDS.DataSpace")
   Set df = ds.CreateObject("RDSServer.DataFactory", _
                            "http://<Server Name>" )
   Set rs = df.Query("DSN=RDSDemo;UID=admin;PWD=;", _
                     "SELECT * FROM Authors") 


Technique #3 - Using the DataSpace to a Custom Business Object


A business object is nothing more than an ActiveX DLL registered on the RDS Server (and perhaps on the client, if you are using DCOM as your protocol). The advantage of this technique is that you can implement conflict resolution, data validation or other functionality within your business object.

There are three protocols you can use to marshall a recordset to the client, HTTP, HTTPS, and DCOM.

When using a custom business object you must add a registry setting to the server where the business object is registered. In the following example the VBCustBusObj.OBJ would need to be added to the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ADCLaunch\VBCustBusObj.OBJ

Consult the RDS Online documentation for details about registry settings that may be required for any custom business object.

The following code demonstrates this technique using VBA:


   
   Dim ds
   Dim bo
   dim rs

   Set ds = CreateObject("RDS.DataSpace")
   Set bo = ds.CreateObject("VBCustBusObj.OBJ", _
                            "http://<Server Name>")
   Set rs = bo.Test3_ReturnRS("DSN=RDSDemo;UID=admin;PWD=;", _
                              "SELECT * FROM Authors")
 


REFERENCES

The code in the following Microsoft Knowledge Base article(s) were taken from the RDSVB sample, which demonstrates using RDS within Visual Basic.


   QNumber                                   Title
   --------------------------------------------------------------------- 
Q183609 FILE: Rdsvb.exe Demonstrates How to Use RDS with Visual Basic

Additional query words: kbdse kbcode kbcrossref


Keywords          : kbRDS 
Version           : WINDOWS:1.5
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: January 30, 1999