Server Property Example (VBScript)

Microsoft ActiveX Data Objects (ADO)

Server Property Example (VBScript)

The following code shows how to set the RDS.DataControl parameter at design time and bind it to a data-aware control using the SQLOLEDB provider. Cut and paste this code into a normal ASP document and name it ServerProp.asp. ASP script will identify your server.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>Server Property Example</TITLE>
</HEAD>
<BODY>
<H2>RDS API Code Examples </H2>
<HR><BR>
<H3>Remote Data Service</H3>

<TABLE DATASRC=#RDS>
    <TR>
        <TD> <SPAN DATAFLD="FirstName"></SPAN> </TD>
        <TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Title"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Type"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Email"></SPAN> </TD>
    </TR>
</TABLE>
<!-- Remote Data Service with Parameters set at Design Time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=RDS HEIGHT=1 WIDTH=1>
    <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>

</BODY>
</HTML>

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 into a normal ASP document and name it ServerProp2.asp. ASP script will identify your server.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>Remote Data Service Server Property Set at Run Time</TITLE>
</HEAD>
<BODY>

<H2>RDS API Code Examples</H2>

<H3>Remote Data Service Server Property Set at Run Time</H3>

<!-- RDS.DataControl with no parameters set at design time -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
    ID=RDC HEIGHT=1 WIDTH=1>
</OBJECT>

<TABLE DATASRC=#RDC>
    <TR>
        <TD> <SPAN DATAFLD="FirstName"></SPAN> </TD>
        <TD> <SPAN DATAFLD="LastName"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Title"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Type"></SPAN> </TD>
        <TD> <SPAN DATAFLD="Email"></SPAN> </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>

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