DataFactory 对象、Query 方法和 CreateObject 方法范例 (VBScript)

该范例使用 RDS.DataSpace 对象的 CreateObject 方法创建 RDSServer.DataFactory 对象。要测试该范例,请将该代码剪切并粘贴到标准 HTML 文档的 <Body></Body> 标记之间,并命名为 ADCapi7.asp。ASP 脚本将标识您的服务器。

<Center><H2>RDS API Code Examples</H2>
<HR><H3>Using Query Method of 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 TYPE=BUTTON NAME="Run" VALUE="Run"><BR>
<H4>Click Run. The CreateObject Method of the
RDS.DataSpace Object Creates an instance of the
RDSServer.DataFactory. 
The Query Method of the RDSServer.DataFactory is used
to bring back a Recordset. </H4>
</Center>
<Script Language="VBScript">
<!--
Dim ADF
Dim strServer
Dim strConnect
Dim strSQLstrServer = "http://<%=Request.ServerVariables _
("SERVER_NAME")%>"
strConnect = "dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;"
strSQL = "Select * from Employee"Sub Run_OnClick()
' 创建 RDSServer.DataFactory 对象
   Dim objADORs
' 获得记录集
Set ADF = ADS1.CreateObject("RDSServer.DataFactory", strServer)
Set objADORs = ADF.Query(strConnect, strSQL)
' 设置 RDS.DataControl 运行时参数
   ADC.Server = strServer
   ADC.SQL = strSQL
   ADC.Connect = strConnect
   ADC.Refresh
End Sub
-->
</Script>
www.51windows.Net