以下范例顯示如何使用具有默認(rèn)業(yè)務(wù)對象 RDSServer.DataFactory 的 RDS.DataSpace 的 CreateObject 方法。要測試該范例,請將其剪切并粘貼到標(biāo)準(zhǔn) HTML 文檔的 <Body></Body> 標(biāo)記之間,然后將其命名為 ADCapi8.asp。ASP 腳本將標(biāo)識服務(wù)器。
<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>
<!-- 運(yùn)行時設(shè)置的具有參數(shù)的 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 strSQL
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
strConnect = "dsn=ADCDemo;UID=ADCDemo;PWD=ADCDemo;"
strSQL = "Select * from Employee"
Sub Run_OnClick()
Dim objADORs '創(chuàng)建 Recordset 對象
Set ADF = ADS1.CreateObject("RDSServer.DataFactory", strServer) '獲取 Recordset
Set objADORs = ADF.Query(strConnect, strSQL)
' 使用 RDS.DataControl 將 Recordset 綁定到網(wǎng)格敏感控件
ADC.SourceRecordset = objADORs
End Sub
-->
</Script>
以下范例顯示如何使用 CreateObject 方法創(chuàng)建自定義業(yè)務(wù)對象 VbBusObj.VbBusObjCls 的實(shí)例。該范例還使用 Active Server Pages 腳本標(biāo)識 Web 服務(wù)器名。要查看完整的范例,請通過范例應(yīng)用程序的選擇器,在“客戶端層”列中選擇“VBScript in Internet Explorer”,并在“中間層”列中選擇“自定義 Visual Basic 業(yè)務(wù)對象”。
Sub Window_OnLoad()
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
Set BO = ADS1.CreateObject("VbBusObj.VbBusObjCls", strServer)
txtConnect.Value = "dsn=pubs;uid=sa;pwd=;"
txtGetRecordset.Value = "Select * From authors for Browse"
End Sub