Microsoft Remote Data ServiceMicrosoft Remote Data Service*
*Contents  *Index  *Topic Contents

RDS.DataSpace Object and CreateObject Method Example

The following example shows how to use the CreateObject method of the RDS.DataSpace with the default business object, RDSServer.DataFactory. To test this example cut and paste this code between the <Body></Body> tags in a normal HTML document and name it ADCapi8.asp. ASP script will identify your server.

<Center><H2>API Code Examples RDS 1.5</H2>
<HR><H3>Using Query Method of RDSServer.DataFactory</H3>

<!-- RDS.DataSpace  ID ADS1-->
<OBJECT ID="ADS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
</OBJECT>

<!-- RDS.DataControl with parameters set at run time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
	ID=ADC>
</OBJECT>

<Object CLASSID="clsid:AC05DC80-7DF1-11d0-839E-00A024A94B3A"
	CODEBASE="http://<%=Request.ServerVariables("SERVER_NAME")%>/MSADC/Samples/Sheridan.cab"
	ID=GRID1 
		datasrc=#ADC
		HEIGHT=125 
		WIDTH=495>
	<PARAM NAME="AllowAddNew"   VALUE="TRUE">
	<PARAM NAME="AllowDelete"   VALUE="TRUE">
	<PARAM NAME="AllowUpdate"   VALUE="TRUE">
	<PARAM NAME="Caption" VALUE="RDSServer.DataFactory Run Time">
</OBJECT>
<HR>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<H4>Click Run. The CreateObject Method of the RDS.DataSpace Object Creates an instance of the RDSServer.DataFactory. 
The Query Method of the RDSServer.DataFactory is used to bring back a Recordset. </H4>
</Center>
<Script Language="VBScript">
<!--
Dim ADF
Dim strServer
Dim strConnect
Dim strSQL
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
strConnect = "dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;"
strSQL = "Select * from Employee"

Sub Run_OnClick()
	Dim objADORs		'Create Recordset Object
Set ADF = ADS1.CreateObject("RDSServer.DataFactory", strServer)				'Get Recordset	
Set objADORs = ADF.Query(strConnect, strSQL)	 
' Use  RDS.DataControl to bind Recordset to Data 
‘ Aware Grid Control

	ADC.SourceRecordset = objADORs

End Sub
-->
</Script>

The following example shows how to use the CreateObject method to instantiate a custom business object, VbBusObj.VbBusObjCls. It also uses the Active Server Pages scripting to identify the Web server name. To see the complete example, choose “VBScript in Internet Explorer” in the Client Tier column and “Custom Visual Basic Business Object” in the Middle Tier column from the sample applications selector.

Sub Window_OnLoad()
	strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
	Set BO = ADS1.CreateObject("VbBusObj.VbBusObjCls", strServer)
	txtConnect.Value = "dsn=pubs;uid=sa;pwd=;"
	txtGetRecordset.Value = "Select * From authors for Browse"
End Sub

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.