选择显示字体大小

asp内置对象 objectcontext详解

     您可以使用 objectcontext 对象提交或放弃一项由 microsoft transaction server (mts) 管理的事务,它由 asp 页包含的脚本初始化。
  
  asp 包含 @transaction 指令时,该页会在事务中运行,直到事务成功或失败后才会终止。
  
  语法
  objectcontext.method
  
  方法
  setcomplete setcomplete 方法声明脚本不了解事务未完成的原因。如果事务中的所有组件都调用 setcomplete,事务将完成。
  setabort setabort 方法声明被脚本初始化的事务未完成,无法更新源。
  
  事件
  ontransactioncommit
  ontransactionabort
  
  注释
  objectcontext 实现 mts objectcontext 对象的两种方法。 setabort 方法完全终止事务。这样,mts 不更新在第一阶段联系的源。事务终止时,将处理脚本的 ontransactionabort 事件。
  
  调用 setcomplete 方法并不一定意味着事务已完成。只有脚本调用的所有事务组件都调用了 setcomplete,事务才能完成。在大多数实例中,如果结束处理时未调用 setabort,脚本通常被假定为完成的,所以不一定要在脚本内调用 setcomplete。
  
  objectcontext 展示了 setabort 和 setcomplete 以外的六种方法。这些方法可用于脚本调用的组件,但不能直接用于 asp 脚本。
  
  示例
  这里示范使用 setabort 和 setcommit 的方法。sales.htm 文件获取处理销售请求所需的数据。第二个文件——salesverify.asp 中的脚本使用两个对象——inventory 和 sales 处理销售。如果 inventory 返回了错误代码表示供销售的存货不足,就会调用 setabort。如果 inventory 对象没有返回错误代码,将会调用 setcomplete 处理销售请求。
  
  sales.htm
  <!doctype html public "-//ietf//dtd html//en">
  
  <html>
  <head>
  <title>sales order</title>
  </head>
  <body bgcolor="#ffffff"><font face="arial,helvetica">
  <h2>sales order form </h2>
  
  <form method=post action="salesverify.asp">
  <p>please enter the product code, quantity, and your account number.
  <input type=text name=quantitytobuy>
  <input type=text name=productcode>
  <input type=text name=accountin>
  <p>
  <input type=submit>
  </font>
  </body>
  </html>
  
  salesverify.asp 文件
  <%@ transaction = required %>
  <%
  set currentqoh = server.createobject("mycomp.inventory")
  set currentsales = server.createobject("mycomp.sales")
  
  checkquantity = request("quantitytobuy")
  checkproduct = request("productcode")
  quantitystatus = currentqoh.checkqoh(checkquantity,checkproduct)
  
  if quantitystatus = none
  objectcontext.setabort
  response.write "sorry, there is not sufficient quantity on hand to process your sale."
  else
  objectcontext.setcomplete
  account = request("accountin")
  saleupdate = currentsales.postit(accountin)
  end if
  %>
  
  
  
    


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons