DataControl Object Example (VBScript)

From Microsoft ActiveX Data Objects (ADO)

DataControl Object Example (VBScript)

The following code shows how to set the RDS.DataControl parameters at design time and bind them to a data-aware control. Cut and paste this code between the <Body></Body> tags in a normal HTML document and name it ADCapi1.asp. ASP script will identify your server.

<H2>RDS API Code Examples</H2>
<HR>
<H3>Remote Data Service</H3>
<TABLE DATASRC=#RDS>
<TBODY>
    <TR>
        <TD><SPAN DATAFLD="FirstName"></SPAN></TD>
        <TD><SPAN DATAFLD="LastName"></SPAN></TD>
    </TR>
</TBODY>
</TABLE>
<!-- Remote Data Service with Parameters set at Design Time -->

<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=RDS>
    <PARAM NAME="SQL" VALUE="Select * from Employee for browse">
    <PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
    <PARAM NAME="CONNECT" VALUE="Provider=SQLOLEDB;User Id=rdsdemo;Password=rdsdemo;Initial Catalog=AddrBookDB">
</OBJECT>

The following example shows how to set the necessary parameters of RDS.DataControl 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 ADCapi2.asp. ASP script will identify your server.

<H2>RDS API Code Examples</H2>
<HR>
<H3>Remote Data Service Run Time</H3>

<TABLE DATASRC=#RDS>
<TBODY>
  <TR>
    <TD><SPAN DATAFLD="FirstName"></SPAN></TD>
    <TD><SPAN DATAFLD="LastName"></SPAN></TD>
  </TR>
</TBODY>
</TABLE>

<!-- RDS.DataControl with no parameters set at design time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=RDS HEIGHT=1 WIDTH=1>
</OBJECT>
<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>
<H4>Fill Grid with these values or change them to see data from another ODBC data source on your server</H4>

<Script Language="VBScript">
<!--
' Set parameters of RDS.DataControl at Run Time
Sub Run_OnClick
    RDS.Server = txtServer.Value
    RDS.SQL = txtSQL.Value
    RDS.Connect = txtConnect.Value
    RDS.Refresh
End Sub
-->
</Script>