The following example shows how to set the necessary parameters of the RDSServer.DataFactory default business object at run time.
To test this example, cut and paste this code between the <Body></Body> tags in a normal HTML document and name it SourceRS.asp. ASP script will identify your server.
<Center>
<H2>RDS API Code Examples</H2>
<HR>
<H3>Using SourceRecordset and Recordset with RDSServer.DataFactory</H3>
<!-- RDS.DataSpace ID RDS1 -->
<OBJECT ID="RDS1" 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=RDC WIDTH=1 HEIGHT=1>
</OBJECT>
<TABLE DATASRC=#RDC>
<TR>
<TD> <INPUT DATAFLD="FirstName" SIZE=15> </TD>
<TD> <INPUT DATAFLD="LastName" SIZE=15 id=text1 name=text1> </TD>
<TD> <INPUT DATAFLD="Title" SIZE=15 id=text2 name=text2> </TD>
<TD> <INPUT DATAFLD="Type" SIZE=15 id=text3 name=text3> </TD>
<TD> <INPUT DATAFLD="Email" SIZE=15 id=text4 name=text4> </TD>
</TR>
</TABLE>
<HR>
<Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
<Input Size=70 Name="txtConnect" Value="Provider=SQLOLEDB;User Id=rdsdemo;Password=rdsdemo;Initial Catalog=AddrBookDB"><BR>
<Input Size=70 Name="txtSQL" Value="Select * from Employee">
<HR>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
</Center>
<Script Language="VBScript">
<!--
Dim ADF
Dim strServer
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
Sub Run_OnClick()
Dim objADORs
' Create RDSServer.DataFactory Object
Set RDF = RDS1.CreateObject("RDSServer.DataFactory", strServer)
' Get Recordset
Set objADORs = RDF.Query(txtConnect.Value,txtSQL.Value)
' Set parameters of RDS.DataControl at run time.
RDC.Server = txtServer.Value
RDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.Value
RDC.Refresh
End Sub
-->
</Script>