📄 3.htm
字号:
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">ADO和RDS适用於那些需要大量存取资料库的应用程式。在为企业内部网路开发一个应用程式时,您通常必须使用IIS
5.0和Internet
Explorer在用户端和商业服务层之间进行通讯。但是如果用户端和中间层元件存在於本机区域网路(LAN)中,您也可以使用COM跨越网路进行介面和方法参数的配置。RDS也可以被用Visual
Basic编写的应用程式进行远端资讯管理。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">有了RDS,ADO可使Web应用程式开发者能够:</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ul style="line-height: 25px">
<li style="line-height: 25px">透过DHTML「资料系结」模式将ADO<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Recordset </b></font>物件和内含在浏览器中的Dynamic
HTML(DHTML)控制项(以及其他的资料感知控制项)结合在一起。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">建立并管理远端以及中断的ADO Recordset物件。ADO通常会与资料库建立一个持久稳定的连线,而
RDS是透过本机快取记忆体的非连线资料来运作的。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">非同步地向伺服器请求资讯,并对操作结束所触发的事件作出反应。非同步的资料索取是OLE
DB的Microsoft Cursor
Service的特有特性。它先为一个查询传回比较前面的记录,然後在使用者处理这些先被传回的资料时,在後端继续处理资料。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">不透过HTTP和COM在Web伺服器上呼叫Automation物件。您可以在应用程式中使用RDS来浏览记录、连线到中间层或更改中间层资料。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">使用分层和多维记录集。透过OLE DB的新Microsoft Data Shaping
Service(Microsoft Datashape),RDS克服了以前每个查询只能有一个结果集的限制。<br style="line-height: 25px">
</li>
</ul>
</font>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">RDS用户端和伺服器端元件将在後面的小节中详细描述。</font></p>
<p><font face="arial" color="#3e72d7" size="4" style="line-height: 25px">
<b style="line-height: 25px">用户端层元件<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
如前章所述,用户端服务层为收集和显示提供了一个看得见的介面。在一个基於Web的RDS应用程式中,Web网页代表了RDS的前端。RDS用户端层包含以下元件:</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ul style="line-height: 25px">
<li style="line-height: 25px">一个包含一个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl </b></font>物件和一或多个资料感知控制项的Web网页或
Visual Basic应用程式。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">一个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataSpace </b></font>物件和中间层商业物件的用户端代理。预设的商业物件是<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDSServer.DataFactory </b></font>,或是您也可以开发自订的商业物件。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">一个OLE DB的资料快取记忆体和用户端资料指标引擎,即OLE DB的Cursor
Service。<br style="line-height: 25px">
</li>
</ul>
</font>
<p><font face="arial" color="#3e74d7" size="3" style="line-height: 25px">
<b style="line-height: 25px">资料感知控制项<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
您可以将资料感知控制项(例如,一个DHTML文字方块、FlexGrid控制项等等)与远端伺服器资料系结在一起,以观看、编辑和更新Web网页的资料。RDS是几种资料系结控制项中唯一可以查询结果并将它们与Internet
Explorer中另一类DHTML元件系结在一起的。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">在RDS中,资料系结装置是RDS.DataControl物件。这是一个看不见的控制项,它可以将一个提供查询结果的ADO
Recordset物件与网页上的一或多个资料感知控制项系结在一起。以下的HTML建立了一个与Mysite伺服器的连线,并查询了Pubs资料库中的所有作者。</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><!-- RDS.DataControl -- >
< OBJECT ID=RDS classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" >
< PARAM NAME="SQL" VALUE="Select from Authors" >
< PARAM NAME="SERVER" VALUE="http://MySite" >
< PARAM NAME="CONNECT" VALUE="dsn=Pubs;UID=sa;PWD=;" >
</ OBJECT ></pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">当使用<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl </b></font>获得一个中断的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Recordset </b></font>时,RDS会呼叫中间层的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDSServer.DataFactory </b></font>物件。您不需要显式呼叫RDSServer.DataFactory
或 RDS.DataSpace。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">当RDS资料库代理呼叫伺服器上的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDSServer.DataFactory </b></font>物件时,伺服器端物件会建立一个ADO
Recordset并对特定的资料来源进行查询。当<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl </b></font>为用户端应用程式重建Recordset时,查询结果被传送到用户端。一旦用户端收到资料,就与资料来源中断,这有助於减少对资料库连线的竞争,因为有时会发生多个用户端同时存取同一个资料来源的情况。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
图3-2展示了一个Internet Explorer中的资料系结方格控制项。当载入网页时,方格控制项被来自Adventure
Works资料库的资料自动填满。以下的程式码显示了用Microsoft Visual Basic Scripting Edition(VBScript)建立一个网页。请注意,事实上在伺服器上只执行了非常少量的指令档,大多数指令档是透过用户端建立的物件操作的。</font></p>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">范例:Sheridan方格控制项<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
本例使用了Sheridan资料系结的方格控制项,它存在於Sheridan网站, </font></a><font face="arial" color="#000000" size="2" style="line-height: 25px"><a target="_new" href="http://www.shersoft.com" style="line-height: 25px">http://www.shersoft.com</a> ,作为MDAC样本的一部分。如果您已经安装了MDAC样本,那麽便可以在http://<您的伺服器>msadc/Samples/ssdatb32.cab找到关於方格控制项的
.cab档案。</font></p>
<p><br style="line-height: 25px">
</p>
<center style="line-height: 25px">
<p>
<input id="1" onclick="imgclick" type="image" src="http://e-msbooks.com/xmlfiles/957-2085-16-6/imagesh/F03dd02.gif" border="0" style="line-height: 25px"></p>
</center><center style="line-height: 25px">
<table border="0" style="line-height: 25px">
<tbody style="line-height: 25px">
<tr style="line-height: 25px">
<td align="middle" style="line-height: 25px">
<font face="arial" color="#000000" size="2" style="line-height: 25px">
图3-2 一个Internet Explorer中的资料系结方格控制项</font></td>
</tr>
</table>
</center>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%@ LANGUAGE=VBScript EnableSessionState=False % >
<!-- #include file="adcvbs.inc" -->
< HTML >
< HEAD >
< TITLE > A databound grid control </ TITLE >
</ HEAD >
< BODY BGCOLOR=#FFFFFF TEXT="#000000" >
<!-- RDS.DataControl -- >
< OBJECT ID="DATA" WIDTH=1 HEIGHT=1
CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" >
</ OBJECT >
<!-- Sheridan data-bound grid control(note DATASRC)-->
< OBJECT ID="GRID" WIDTH=600 HEIGHT=200 DATASRC="#DATA"
CLASSID="clsid:00028C00-0000-0000-0000-000000000046" >
</ OBJECT >
--> < SCRIPT Language=VBScript >
Sub Window_OnLoad
If DATA.ReadyState <> <%=adc ReadyStateComplete% > Then
MsgBox "Query results still arriving, Please wait"
Else
DATA.Server = "http:// <% Request.ServerVariables(" SERVER_NAME")%>"
DATA.Connect = "DSN=AdvWorks"
DATA.SQL = "Select from Products"
DATA.Refresh
GRID.Rebind
End if
END SUB
</ SCRIPT >
</ BODY >
</ HTML ></pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">每个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl </b></font>物件可被连往不同的资料来源并可容纳各个查询的结果。当您使用<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl </b></font>物件向资料库发送请求时,RDS伺服器端元件传回给用户端一个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> ADODB.Recordset </b></font>物件,接着RDS代理建立一个用户端和一个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> ADOR.Recordset </b></font>物件以操纵传回的记录。您不需要为这一切写任何ADO程式码-当您使用RDS.DataControl物件时,RDS会帮您处理这一切。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
图3-3显示了基於Web的ADO应用程式的用户端和伺服器端元件是如何共同运作以处理使用者的请求并显示资料库的资讯。</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ol style="line-height: 25px">
<li style="line-height: 25px">使用者输入请求文字、选择一个预设的请求、或浏览到一个包含嵌入式请求的网页。 </li>
<li style="line-height: 25px">当在一个网页上有事件发生时,例如<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Window_OnLoad </b></font>程式或一个Search按钮的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> OnClick </b></font>事件,ADO便在用户端建立一个<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDSServer.DataFactory </b></font>代理(或商务物件代理)。
</li>
<li style="line-height: 25px">代理透过把商务物件方法的参数格式化成
URL参数,将使用者的请求转化为一个HTTP请求。然後,它将这一请求送往 Web伺服器指定的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataControl
Server </b></font>属性。IIS 5.0继续将HTTP请求送往一个Internet Server Application
Programming Interface(ISAPI)延伸。 </li>
<li style="line-height: 25px">Advanced Data ISAPI(ADISAPI)解释URL参数,建立一个被请求商务物件的例项,并进行方法呼叫(在预设情况下,它呼叫伺服器端<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> RDS.DataFactory </b></font>物件的Query方法)。
</li>
<li style="line-height: 25px">
<font face="arial" color="#3e80d7" size="2" style="line-height: 25px">
<b style="line-height: 25px"> RDS.DataFactory </b></font>物件透过OLE
DB执行使用者的查询。它设定<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Recordset </b></font>的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> CursorLocation </b></font>属性以使Cursor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -