DataControl 对象范例 (VBScript)

以下代码显示如何在设计时设置 RDS.DataControl 参数以及如何使用称为 ADCDemo 的 ODBC 数据源将其绑定到数据标识的控件当中。如果您按照指导操作,ADCDemo 将作为 SQL Server ODBC 数据源安装到服务器上。请将其剪切并粘贴到标准 HTML 文档的 <Body></Body> 标记之间,然后将其命名为 ADCapi1.asp。ASP 脚本将标识服务器。

<Center><H2>RDS API Code Examples</H2>
<HR><BR>
<H3>Remote Data Service</H3>
<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">
</OBJECT>
<!-- 设计时设置的具有参数的 Remote Data Service -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
   ID=ADC>
   <PARAM NAME="SQL" VALUE="Select * from Employee for browse">
   <PARAM NAME="SERVER" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>">
   <PARAM NAME="CONNECT" VALUE="dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;">
</OBJECT><BR><HR></Center>

以下范例显示如何在运行时设置 RDS.DataControl 的必要参数。要测试该范例,请将其剪切并粘贴到标准 HTML 文档的 <Body></Body> 标记之间,然后将其命名为 ADCapi2.asp。ASP 脚本将标识服务器。

<Center><H2>RDS API Code Examples </H2>
<HR><BR>
<H3>Remote Data Service Run Time</H3>
<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="Remote Data Service Run Time">
</OBJECT><!-- 设计时设置的不带参数的 RDS.DataControl -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
   ID=ADC>
   </OBJECT>
<HR>
<Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
<Input Size=70 Name="txtConnect" Value="dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;">
<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>
</Center>
<Script Language="VBScript">
<!--
' 在运行时设置 RDS.DataControl 的参数
Sub Run_OnClick
   ADC.Server = txtServer.Value
   ADC.SQL = txtSQL.Value
   ADC.Connect = txtConnect.Value
   ADC.Refresh
End Sub
-->
</Script>
www.51windows.Net