Connect 属性范例

该代码演示如何在设计时设置 Connect 属性:

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="ADC1">
.
.
.
   <PARAM NAME="SQL" VALUE="Select * from Sales">
   <PARAM NAME="Connect" VALUE="DSN=pubs;UID=sa;PWD=;">
   <PARAM NAME="Server" VALUE="http://MyWebServer">
.
.
.
</OBJECT>

以下范例演示如何以 VBScript 代码在运行时设置 Connect 属性。

要测试该范例,请剪切该代码并粘贴到标准 HTML 文档的 <Body></Body> 标记之间,然后将其命名为“ADCapi3.asp”。ASP 脚本将标识服务器。

<Center><H2>RDS API Code Examples </H2>
<HR>
<H3>Set Connect Property at Run Time</H3>
<!-- 在设计时设置无参数 RDS.DataControl  -->
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
   ID=ADC>
   </OBJECT>
<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 Connect Property at Run Time">
</OBJECT>
<HR>
<Input Size=70 Name="txtServer" Value="http://<%=Request.ServerVariables("SERVER_NAME")%>"><BR>
<Input Size=70 Name="txtConnect"><BR>
<Input Size=70 Name="txtSQL" Value="Select * from Employee">
<HR>
<INPUT TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<H4>To Fill Grid enter Connect String in middle text box<BR>
Try dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;</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.2mysite.net