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

RDSServer.DataFactory Object, Query Method, and CreateObject Method Example

This example creates a RDSServer.DataFactory object using the CreateObject method of the RDS.DataSpace object. To test this example, cut and paste this code between the <Body></Body> tags in a normal HTML document and name it ADCapi7.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 RDSServer.DataFactory Object
Set ADF = ADS1.CreateObject("RDSServer.DataFactory", strServer)				'Get Recordset
Set objADORs = ADF.Query(strConnect, strSQL)
' Set parameters of RDS.DataControl at Run Time

	ADC.Server = strServer
	ADC.SQL = strSQL
	ADC.Connect = strConnect
	ADC.Refresh
End Sub
-->
</Script>

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