The following example shows how to set the necessary parameters of RDS.DataControl at run time. The manner in which a Recordset is retrieved using the Refresh method is determined by the settings of the ExecuteOptions and FetchOptions properties. To test this example, cut and paste this code into a normal ASP document and name it Refresh.asp. ASP script will identify your server.
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<H2>RDS API Code Examples </H2>
<HR>
<TABLE DATASRC=#RDC>
<TR>
<TD> <INPUT DATAFLD="FirstName" SIZE=15 id=text5 name=text5> </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>
<!-- RDS.DataControl with no parameters set at design time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDC HEIGHT=1 WIDTH=1>
</OBJECT>
<HR>
Server: <Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
Connect: <Input Size=70 Name="txtConnect" Value="Provider=SQLOLEDB;User Id=rdsdemo;Password=rdsdemo;Initial Catalog=AddrBookDB"><BR>
SQL: <Input Size=70 Name="txtSQL" Value="Select * from Employee">
<HR>
<TABLE BORDER=1 WIDTH="60%">
<TR>
<TD COLSPAN=3 BGCOLOR=silver>
Choose if you want the Recordset brought back Synchronously on the
current calling thread or Asynchronously on another thread.
</TD>
</TR>
<TR>
<TD>Synchronously: <BR>
<Input Type="Radio" Name="optExecuteOptions" Checked OnClick="SetExO('adcExecSync')">
</TD>
<TD>Asynchronously: <BR>
<Input Type="Radio" Name="optExecuteOptions" OnClick="SetExO('adcExecAsync')">
</TD>
<TD> </TD>
</TR>
<TR>
<TD COLSPAN=3 BGCOLOR=silver>
Fetch Up Front, Background Fetch with Blocking or Background Fetch
without Blocking
</TD>
<TR>
<TD>Up Front:<BR>
<Input Type="Radio" Name="optFetchOptions" OnClick="SetFO('adcFetchUpFront')">
</TD>
<TD>Background w/ Blocking:<BR>
<Input Type="Radio" Name="optFetchOptions" Checked OnClick="SetFO('adcFetchBackground')">
</TD>
<TD>Background w/o Blocking:<BR>
<Input Type="Radio" Name="optFetchOptions" OnClick="SetFO('adcFetchAsync')">
</TD>
</TR>
</TABLE>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<Script Language="VBScript">
<!--
Dim EO 'ExecuteOptions
Dim FO 'FetchOptions
EO = "adcExecSync" 'Default value
FO = "adcFetchBackground" 'Default value
Sub SetExO(NewEO)
EO = NewEO
End Sub
Sub SetFO(NewFO)
FO = NewFO
End Sub
' Set parameters of RDS.DataControl at Run Time
Sub Run_OnClick
RDC.Server = txtServer.Value
RDC.SQL = txtSQL.Value
RDC.Connect = txtConnect.Value
If EO = "adcExecSync" Then 'Determine which ExecuteOption chosen
RDC.ExecuteOptions = adcExecSync
MsgBox "Recordset brought in on current calling thread Syncronously"
Else
RDC.ExecuteOptions = adcExecAsync
MsgBox "Recordset brought in on another thread Asyncronously"
End If
If FO = "adcFetchBackground" Then 'Determine ‘which FetchOption chosen
RDC.FetchOptions = adcFetchBackground
MsgBox "Control goes back to user after first batch of records returned"
ElseIf FO = " adcFetchUpFront" Then
RDC.FetchOptions = adcFetchUpFront
MsgBox "All records returned before control goes back to user"
Else
RDC.FetchOptions = adcFetchAsync
MsgBox "Control goes back to user immediately"
End If
RDC.Refresh
End Sub
-->
</Script>
</BODY>
</HTML>