HOWTO: Use RDS Within a Visual Basic ActiveX Document
ID: Q184630
|
The information in this article applies to:
-
Remote Data Service for ADO versions 1.1, 1.5, 2.0, 2.1 SP2
-
Microsoft Visual Basic Professional and Enterprise Editions for Windows, versions 5.0, 6.0
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 INFORMATIONCreate the Visual Basic ActiveX Document Client
- Create a new Visual Basic (VB) ActiveX Document EXE project. Select the Project and name the project Rdsclient.
- Place a Command button on the form.
- 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
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
- Change the <Server> code to reflect the Internet Information Server (IIS) server where the ActiveX document and the RDS Server components will reside.
- Save the ActiveX Document Project.
Creating an Internet Download Setup for the ActiveX Document
- Exit Visual Basic 5.0. Use the Application Setup Wizard to package the ActiveX document for Internet download. From the Start menu, select
Programs, and then select Visual Basic 5.0 and click Application Setup Wizard. You can start the Package and Deployment Wizard distributed with Visual Basic 6.0 the same way or you can start it as an add-in within Visual Basic.
- 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 the Create Internet Download Setup" option, and then click
Next. The PDW asks you for a script name before you get to the screen where you select Internet Package.
- Choose the destination location. This is where the setup files created by the Application Wizard are stored. The setup files consist of the .cab, .htm, .vbd files and a support folder. Visual Basic 6.0 creates a package subdirectory and place the .cab, .htm, and .vbd files in there. Click Next and you see a list of included files. Accept the default here.
- Click Next and then choose Download from Microsoft Web site for the run-time components. Click the safety button, select the Safe for
Initialization and Safe for Scripting check boxes, and then click OK.
Click Next to continue to the next screen. In Visual Basic 6.0 these two items are on a the next screen called Safety Settings.
- On the ActiveX Server Components screen, click Next.
- Accept the default files for distribution and click Next. In Visual Basic 6.0 you have already done this on a previous screen.
- Click Finish.
- Copy the generated files (.cab, .htm, .vbd and the support folder) into the Webserver root directory. In Visual Basic 6.0 you can use the deploy button in the first screen of the PDW to accomplish the same thing.
- Access the .htm file from the Browser through http as follows:
http://<IIS server>/RdsClient.htm
- You should be able to see the ActiveX document. Click the Command button and note that a message box showing the first recordset is displayed.
NOTE: Because the component is not signed, you see warnings regarding the download of the component. Before the actual distribution of your application, you should have the components signed.
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 white paper "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://msdn.microsoft.com/library/techart/msdn_redistmdac.htm
For additional information, please see the following World Wide Web URLs:
http://www.microsoft.com/data/
For more information regarding RDS, please see the following articles in
the Microsoft Knowledge Base:
Q168428 HOWTO: Test Your ActiveX Documents (.VBD)
Q176810 HOWTO: Manually Modify and Rebuild CAB Files
Q199017 HOWTO Deploy Visual Basic IIS Applications with PDW
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Wendy Aldrich, Microsoft Corporation.
Additional query words:
ADC mdacRedist rdsvb
Keywords : kbDatabase kbVBp500 kbVBp600 kbGrpVBDB kbGrpMDAC kbDSupport kbRDS210SP2 kbMDAC210SP2
Version : WINDOWS:1.1,1.5,2.0,2.1 SP2,5.0,6.0
Platform : WINDOWS
Issue type : kbhowto
|