HOWTO: Use RDS Within a Visual Basic ActiveX Document

ID: Q184630


The information in this article applies to:


SUMMARY

This article explains how to create an ActiveX document that uses the Remote Data Services of ADO (RDS) and how to distribute the document to Internet Explorer clients.


MORE INFORMATION

Create the Visual Basic ActiveX Document Client

  1. Create a new Visual Basic (VB) ActiveX Document EXE project. Select the Project and name the project Rdsclient.


  2. Place a Command button on the form.


  3. Depending on the version of Internet Explorer the clients are using to access the ActiveX Document, the code may differ slightly. Internet Explorer version 4.01 includes the RDS 1.5 client components. When accessing Internet Explorer 4.01 the RDS.DataSpace or RDS.DataControl syntax is used.

    If Internet Explorer 3.02 clients are accessing the ActiveX Document use the RDS 1.1 client components. Internet Explorer 3.02 does not include any RDS components and the Msadc11.cab file that includes the RDS 1.1 client components needs to be added to the resulting ActiveX Documents .inf file. The syntax you use for the Internet Explorer 3.02 clients follows:
    
          RDSIE3.DataSpace or RDSIE3.DataControl 


  4. Paste the following code into the General Declarations section of the project:
    
       Option Explicit
    
       Private Sub Command1_Click()
          Dim rs As Object   'Resultset
          Dim ds As Object   'RDS.DataSpace
          Dim df As Object   'RDSServer.DataFactory
    
          'For use with Internet Explorer 3.02
          'Set ds = CreateObject("RDSIE3.DataSpace")
    
          'For use with Internet Explorer 4.01
          Set ds = CreateObject("RDS.DataSpace")
    
          
          Set df = ds.CreateObject("RDSServer.DataFactory", _
          "http://<Server>")
    
          'This query returns a recordset over HTTP.
          Dim strCn As Variant, strSQL As Variant
          strCn = "dsn=advworks"
          strSQL = "Select * from Products"
          Set rs = df.Query(strCn, strSQL)
          MsgBox rs(0)     'Print 1 to MsgBox
       End Sub
     


  5. Change the <Server> code to reflect the Internet Information Server (IIS) server where the ActiveX document and the RDS Server components will reside.


  6. Save the ActiveX Document Project.


Creating an Internet Download Setup for the ActiveX Document

  1. Exit Visual Basic 5.0. Use the Application Setup Wizard to package the ActiveX document for Internet download. From the Start menu, point to Programs, and then point to Visual Basic 5.0 and click "Application Setup Wizard".


  2. Choose Browse and select the ActiveX Document project that you just created. By default, the program saves the application to the location where Visual Basic is installed. The name of the file is RdsClient.vbp. Select "Create Internet Download Setup" from the options, and then click Next.


  3. Choose the destination location. This is where the setup files created by the Application Wizard are stored. The setup files consists of the .cab, .htm, .vbd files and a support folder.


  4. Click Next, and then choose "Download from Microsoft Web site" for the run-time components. Click the safety button, and select the "Safe for Initialization" and "Safe for Scripting" check boxes, and then click OK. Click Next to continue to the next screen.


  5. On the ActiveX Server Components screen, click Next.


  6. Accept the default files for distribution and click Next.


  7. Click Finish.


  8. Copy the generated files (.cab, .htm, .vbd and the support folder) into the Webserver root directory.


  9. If the Browser is Internet Explorer 3.02 you need to modify the resulting ActiveX Document .inf file to include a file named Msadc11.cab. This is because Internet Explorer 3.02 does not include the necessary client files required by Remote Data Service, while Internet Explorer 4.01 includes the files. Skip to the "Including the Msadc11.cab for Internet Explorer 3.02 Browsers" section for details on how to include the Msadc11.cab file.


  10. Access the .htm file from the Browser via http as follows:
    
           http://<IIS server>/RdsClient.htm 


  11. You should be able to see the ActiveX document. Click the Command button and a message box showing the first recordset displays.


NOTE: Since the component is not signed, you will see warnings regarding the download of the component. Before the actual distribution of your application, you should have the components signed.

Including the Msadc11.cab for Internet Explorer 3.02 Browsers

The .inf file is in the Support folder created with the Visual Basic Setup Wizard. Modify the ActiveX Document .inf file as shown in the following steps.
  1. In the Add.Code section, add the following DLL reference as the first DLL:
    
       [Add.Code]
       MSADCB11.DLL=MSADCB11.DLL 


  2. Add the following two tags after the Add.Code section:
    
       [MSADCB11.DLL]
       hook=msadc11.cab_Installer
       FileVersion=1,1,2022,0
    
       [msadc11.cab_Installer]
       file-win32-x86=msadc11.cab
       InfFile=msadc11.inf
     
    NOTE: Make sure that you download the newest Msadc11.cab file available from the following Web site:
    
          http://www.microsoft.com/data/  


  3. Save the .inf file.


  4. After editing the .inf file you need to re-cab your components. Although the Visual Basic Setup Wizard created a CAB file for your application, you must re-cab your components to reflect the changes in the .inf file.

    You can use Cabarc.exe to make your CAB file. You can find Cabarc.exe and the entire CAB SDK at the following Web site:
    
           http://www.microsoft.com/workshop/prog/cab/cabdl.htm 
    Download the SDK and extract it into the appropriate directory.


  5. Locate the directory of the Cabarc.exe file. Add the appropriate files for the ActiveX Document project to this directory. This includes the ActiveX Doc.exe and the ActiveX Doc.inf created with the Visual Basic setup wizard.


  6. Create your new CAB file. From the Command prompt you would type the following:
    
       CABARC n nameofyourcab.cab nameoftheActiveXDoc.exe nameoftheinf.inf 


  7. Move the new ActiveX Document CAB file along with the Msadc11.cab file into the Internet Information Server (IIS) directory.


  8. Test the application. Access the .htm file from the Browser through http as follows:
    
           http://<IIS server>/RdsClient.htm 


  9. You should see the ActiveX document. Click the Command button and a message box showing the first recordset displays.


When using the new Msadc11.cab the following error message may display:
Error registering the OCX c:\windows\occache\msadco.dll
This is a known bug in the CAB file and you can ignore the error. The Msadco.dll file is a RDS 1.5 client component that is referenced incorrectly in the Msadc11.cab. The error only displays the first time the client downloads the CAB file.


REFERENCES

This article is one of a series dealing with redistribution of MDAC components; ODBC, OLE DB, ADO, RDS, the MDAC Standalone, MDAC Redistribution and the Data Access SDK. The whitepaper "Redistributing Microsoft Data Access Components" presents a comprehensive overview of this subject, including referencing the content in this Knowledge Base article. This whitepaper is located at the following URL:

http://www.microsoft.com/msdn/news/feature/datajul98/redistmdac.htm

For additional information, please see the following World Wide Web URL:

http://www.microsoft.com/data/

For more information regarding RDS, please see the following articles in the Microsoft Knowledge Base:

Q181092 FAQ: Remote Data Service (RDS) Frequently Asked Questions

Q168428 HOWTO: Test Your ActiveX Documents (.VBD)

Q176810 HOWTO: Manually Modify and Rebuild CAB Files

(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Wendy Aldrich, Microsoft Corporation.

Additional query words: ADC mdacRedist rdsvb kbdse


Keywords          : 
Version           : WINDOWS:1.1,1.5,5.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: June 14, 1999