SubmitChanges 方法示例 (VBScript)
重要
从 Windows 8 和 Windows Server 2012 开始,Windows 操作系统不再包含 RDS 服务器组件(有关更多详细信息,请参阅 Windows 8 和 Windows Server 2012 兼容性实用手册)。 Windows 的未来版本中将移除 RDS 客户端组件。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。 使用 RDS 的应用程序应迁移到 WCF 数据服务。
以下代码片段演示如何将 SubmitChanges 方法与 RDS.DataControl 对象配合使用。
若要测试此示例,请将此代码剪切并粘贴到标准 ASP 文档中,并将其命名为 SubmitChangesCtrlVBS.asp。 ASP 脚本将标识服务器。
<!-- BeginCancelUpdateVBS -->
<%@Language=VBScript%>
<%'Option Explicit%>
<% 'use the following META tag instead of adovbs.inc%>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Remote Data Service</H1>
<H2>SubmitChanges and CancelUpdate Methods</H2>
<% ' to integrate/test this code replace the Server property value and
' the Data Source value in the Connect property with identical values%>
<HR>
<OBJECT id="RDS" classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33" HEIGHT="1" WIDTH="1"></OBJECT>
<SCRIPT Language="VBScript">
'set RDS properties for control just created
RDS.Server = "https://<%=Request.ServerVariables("SERVER_NAME")%>"
RDS.Connect = "Provider='sqloledb';Integrated Security='SSPI';Initial Catalog='Northwind';"
RDS.SQL = "Select * from Employees"
RDS.Refresh
</SCRIPT>
<TABLE DATASRC="#RDS">
<THEAD>
<TR ID="ColHeaders">
<TH>ID</TH>
<TH>FName</TH>
<TH>LName</TH>
<TH>Title</TH>
<TH>Hire Date</TH>
<TH>Birth Date</TH>
<TH>Extension</TH>
<TH>Home Phone</TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD> <INPUT DATAFLD="EmployeeID" size=4 id=text1 name=text1> </TD>
<TD> <INPUT DATAFLD="FirstName" size=10 id=text2 name=text2> </TD>
<TD> <INPUT DATAFLD="LastName" size=10 id=text3 name=text3> </TD>
<TD> <INPUT DATAFLD="Title" size=10 id=text4 name=text4> </TD>
<TD> <INPUT DATAFLD="HireDate" size=10 id=text5 name=text5> </TD>
<TD> <INPUT DATAFLD="BirthDate" size=10 id=text6 name=text6> </TD>
<TD> <INPUT DATAFLD="Extension" size=10 id=text7 name=text7> </TD>
<TD> <INPUT DATAFLD="HomePhone" size=8 id=text8 name=text8> </TD>
</TR>
</TBODY>
</TABLE>
<HR>
<INPUT TYPE=button NAME="SubmitChange" VALUE="Submit Changes">
<INPUT TYPE=button NAME="CancelChange" VALUE="Cancel Update">
<BR>
<H4>Alter a current entry on the grid. Move off that Row. <BR>
Submit the Changes to your DBMS or cancel the updates. </H4>
</CENTER>
<SCRIPT Language="VBScript">
Sub SubmitChange_OnClick
msgbox "Changes will be made"
RDS.SubmitChanges
RDS.Refresh
End Sub
Sub CancelChange_OnClick
msgbox "Changes will be cancelled"
RDS.CancelUpdate
RDS.Refresh
End Sub
</SCRIPT>
</BODY>
</HTML>
<!-- EndCancelUpdateVBS -->