×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

RDS Tutorial (VBScript)

本文发表在 rolia.net 枫下论坛This is the RDS Tutorial, written in Microsoft Visual Basic Scripting Edition. For a description of the purpose of this tutorial, see the RDS Tutorial.

In this tutorial, RDS.DataControl and RDS.DataSpace are created at design time—that is, they are defined with object tags, like this: <OBJECT>...</OBJECT>. Alternatively, they could be created at run time with the Server.CreateObject method. For example, the RDS.DataControl object could be created like this:

Set DC = Server.CreateObject("RDS.DataControl")
<!-- RDS.DataControl -->
<OBJECT
ID="DC1" CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E33">
</OBJECT>

<!-- RDS.DataSpace -->
<OBJECT
ID="DS1" WIDTH=1 HEIGHT=1
CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">

Sub RDSTutorial()
Dim DF1
Step 1—Specify a server program

VBScript can discover the name of the IIS Web server it is running on by accessing the VBScript Request.ServerVariables method available to Active Server Pages:

"http://<%=Request.ServerVariables("SERVER_NAME")%>"
However, for this tutorial, use the imaginary server, "yourServer".

Note Pay attention to the data type of ByRef arguments. VBScript does not let you specify the variable type, so you must always pass a Variant. When using HTTP, RDS will allow you to pass a Variant to a method that expects a non-Variant if you invoke it with the RDS.DataSpace object CreateObject method. When using DCOM or an in-process server, match the parameter types on the client and server sides or you will receive a "Type Mismatch" error.
Set DF1 = DS1.CreateObject("RDSServer.DataFactory", "http://yourServer")
Step 2a—Invoke the server program with RDS.DataControl

This example is merely a comment demonstrating that the default behavior of the RDS.DataControl is to perform the specified query.

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
<PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
<PARAM NAME="Connect" VALUE="DSN=Pubs;">
<PARAM NAME="Server" VALUE="http://yourServer/">
</OBJECT>
...
<SCRIPT LANGUAGE="VBScript">

Sub RDSTutorial2A()
Dim RS
DC1.Refresh
Set RS = DC1.Recordset
...
Step 2b—Invoke the server program with RDSServer.DataFactory

Step 3—Server obtains a Recordset

Step 4—Server returns the Recordset

Set RS = DF1.Query("DSN=Pubs;", "SELECT * FROM Authors")
Step 5—DataControl is made usable by visual controls

' Assign the returned recordset to the DataControl.

DC1.SourceRecordset = RS
Step 6a—Changes are sent to the server with RDS.DataControl

This example is merely a comment demonstrating how the RDS.DataControl performs updates.

<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
<PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
<PARAM NAME="Connect" VALUE="DSN=Pubs;">
<PARAM NAME="Server" VALUE="http://yourServer/">
</OBJECT>
...
<SCRIPT LANGUAGE="VBScript">

Sub RDSTutorial6A()
Dim RS
DC1.Refresh
...
Set RS = DC1.Recordset
' Edit the Recordset object...
' The SERVER and CONNECT properties are already set from Step 2A.
Set DC1.SourceRecordset = RS
...
DC1.SubmitChanges
Step 6b—Changes are sent to the server with RDSServer.DataFactory

DF.SubmitChanges "DSN=Pubs", RS

End Sub
</SCRIPT>
</BODY>
</HTML>
This is the end of the tutorial.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请教:ASP里面RECORDSET可不可以和数据库联席起来,比如说我用页面上的INPUT TYPE=“TXT” ,当输入数据的时候就相当与直接更改DATABASE里面一个记录项的内容?如果可以的话,我就不需要用什么SUBMIT再去SQL语句操作数据库了。
    • 用RDS或XML
      • 呵呵,不懂,XML到听说过,RDS是什么?
        • Remote Data Service
          The Microsoft&reg; Remote Data Service (RDS) delivers a new Web data access technology that allows developers to create data-centric applications within ActiveX&reg;-enabled browsers such as Microsoft&reg; Internet Explorer. RDS creates a framework that permits easy interaction with ODBC databases on corporate intranets and over the Internet. In addition, the design of the Remote Data Service offers a programming model that leverages the knowledge of Visual Basic&reg; developers. RDS provides the advantages of client-side caching of data results, updatable data, and support for data-aware ActiveX controls.
        • RDS Tutorial (VBScript)
          本文发表在 rolia.net 枫下论坛This is the RDS Tutorial, written in Microsoft Visual Basic Scripting Edition. For a description of the purpose of this tutorial, see the RDS Tutorial.

          In this tutorial, RDS.DataControl and RDS.DataSpace are created at design time—that is, they are defined with object tags, like this: <OBJECT>...</OBJECT>. Alternatively, they could be created at run time with the Server.CreateObject method. For example, the RDS.DataControl object could be created like this:

          Set DC = Server.CreateObject("RDS.DataControl")
          <!-- RDS.DataControl -->
          <OBJECT
          ID="DC1" CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E33">
          </OBJECT>

          <!-- RDS.DataSpace -->
          <OBJECT
          ID="DS1" WIDTH=1 HEIGHT=1
          CLASSID="CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36">
          </OBJECT>

          <SCRIPT LANGUAGE="VBScript">

          Sub RDSTutorial()
          Dim DF1
          Step 1—Specify a server program

          VBScript can discover the name of the IIS Web server it is running on by accessing the VBScript Request.ServerVariables method available to Active Server Pages:

          "http://<%=Request.ServerVariables("SERVER_NAME")%>"
          However, for this tutorial, use the imaginary server, "yourServer".

          Note Pay attention to the data type of ByRef arguments. VBScript does not let you specify the variable type, so you must always pass a Variant. When using HTTP, RDS will allow you to pass a Variant to a method that expects a non-Variant if you invoke it with the RDS.DataSpace object CreateObject method. When using DCOM or an in-process server, match the parameter types on the client and server sides or you will receive a "Type Mismatch" error.
          Set DF1 = DS1.CreateObject("RDSServer.DataFactory", "http://yourServer")
          Step 2a—Invoke the server program with RDS.DataControl

          This example is merely a comment demonstrating that the default behavior of the RDS.DataControl is to perform the specified query.

          <OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
          <PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
          <PARAM NAME="Connect" VALUE="DSN=Pubs;">
          <PARAM NAME="Server" VALUE="http://yourServer/">
          </OBJECT>
          ...
          <SCRIPT LANGUAGE="VBScript">

          Sub RDSTutorial2A()
          Dim RS
          DC1.Refresh
          Set RS = DC1.Recordset
          ...
          Step 2b—Invoke the server program with RDSServer.DataFactory

          Step 3—Server obtains a Recordset

          Step 4—Server returns the Recordset

          Set RS = DF1.Query("DSN=Pubs;", "SELECT * FROM Authors")
          Step 5—DataControl is made usable by visual controls

          ' Assign the returned recordset to the DataControl.

          DC1.SourceRecordset = RS
          Step 6a—Changes are sent to the server with RDS.DataControl

          This example is merely a comment demonstrating how the RDS.DataControl performs updates.

          <OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" ID="DC1">
          <PARAM NAME="SQL" VALUE="SELECT * FROM Authors">
          <PARAM NAME="Connect" VALUE="DSN=Pubs;">
          <PARAM NAME="Server" VALUE="http://yourServer/">
          </OBJECT>
          ...
          <SCRIPT LANGUAGE="VBScript">

          Sub RDSTutorial6A()
          Dim RS
          DC1.Refresh
          ...
          Set RS = DC1.Recordset
          ' Edit the Recordset object...
          ' The SERVER and CONNECT properties are already set from Step 2A.
          Set DC1.SourceRecordset = RS
          ...
          DC1.SubmitChanges
          Step 6b—Changes are sent to the server with RDSServer.DataFactory

          DF.SubmitChanges "DSN=Pubs", RS

          End Sub
          </SCRIPT>
          </BODY>
          </HTML>
          This is the end of the tutorial.更多精彩文章及讨论,请光临枫下论坛 rolia.net