Microsoft KB Archive/247865
Article ID: 247865
Article Last Modified on 5/10/2006
- Microsoft Transaction Services 2.0
This article was previously published under Q247865
This article explains how to use Remote Data Services (RDS) from a Visual Basic client to access your MTS components through HTTP. This service is useful when you want to extend the reach of your MTS applications beyond your local Intranet or a Web browser that uses ASP.
RDS is a programming model that uses an intermediate service, such as IIS, to obtain and manipulate data and objects. This intermediate service actually creates the object and allows the client code to access that object as if the client created the object itself. The complete object model and documentation for RDS can be found here:
IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:
256986 Description of the Microsoft Windows Registry
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
Following is an explanation illustrating how to create an MTS component, installing the component into MTS, and creating a Visual Basic client application that access the MTS component through HTTP.
Create a Simple MTS Component
- Create a new ActiveX DLL project.
- Rename the project to "Calculate" and Class1 to CCalculate.
Insert the following code into the CCalculate class module:
Public Function GetSum(ByVal Num1 As Integer, ByVal Num2 As Integer) As Integer GetSum = Num1 + Num2 End Function
- Compile the project and make the DLL.
Setting up MTS
- Install the compiled DLL into MTS.
- Create a new Package in the MTS Explorer and set it's Identity to run as a user other than Interactive.
- Add the Calculate.dll file to the components folder.
- In order to get RDS to invoke the MTS component, a registry key must be added that tells IIS that it is ok to create your object.
Add the following key:
Create the Visual Basic Client
- Begin by creating a new Standard EXE project.
- On Form1 add two Text Boxes (Text1 and Text2) and a Command Button (Command1).
Add the following code to the Form:
Private Sub Command1_Click() Dim rds As Object Dim objCCalculate As Object Set rds = CreateObject("RDS.DataSpace") Set objCCalculate = rds.CreateObject("Calculate.CCalculate", "http://YourHTTPServerName") MsgBox objCCalculate.GetSum(CInt(Text1), CInt(Text2)) Set rds = Nothing Set objCCalculate = Nothing End Sub
When the client executes and you click Command, RDS asks the Web Server to create the MTS object. The Web Server then returns a reference to the MTS object and the client can use the reference as it would any other MTS object.
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
166277 How To Create a VB Component that Returns a Recordset in RDS
Keywords: kbhowto kbdatabase KB247865