Recordset 和 SourceRecordset 属性范例

该范例演示如何在运行时设置 RDSServer.DataFactory 默认业务对象所必需的参数。要测试该范例,请剪切代码并粘贴到标准 HTML 文档的 <Body></Body> 标记之间,然后将其命名为“ADCapi4.asp”。ASP 脚本将标识服务器。

<Center><H2>RDS API Code Examples</H2>
<HR>
<H3>Using SourceRecordset and Recordset with RDSServer.DataFactory</H3>
<!-- RDS.DataSpace ID ADS1 -->
<OBJECT ID="ADS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
</OBJECT><!--参数在运行时设置的 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="RDSServer.DataFactory Run Time">
</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.
<BR>Try dsn=pubs;uid=sa;pwd=; and Select * From Authors</H4>
</Center>
<Script Language="VBScript">
<!--
Dim ADF
Dim strServer
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"Sub Run_OnClick()
   Dim objADORs         ' 创建 RDSServer.DataFactory 对象。
Set ADF = ADS1.CreateObject("RDSServer.DataFactory", strServer)               ' Get Recordset
Set objADORs = ADF.Query(txtConnect.Value,txtSQL.Value)' 在运行时设置 RDS.DataControl 的参数。
   ADC.Server = txtServer.Value
   ADC.SQL = txtSQL.Value
   ADC.Connect = txtConnect.Value
   ADC.Refresh
End Sub
-->
</Script>
www.2mysite.net