heh

《ASP网络开发入门与事件》(附:源码下载)

第三章. application对象

Application对象成员

  • Contents
  • StaticObjects
  • 方法Contents.Remove("var") ,Contents.RemoveAll      移除Contents集合中的变量
  • Lock()
  • Unlock(count)
  • OnStart
  • OnEnd

Application对象的属性和方法

创建:<%Application("对象名")=值%>    

  例如:Application("counter")=1000      访问对象的值:Counter= Application("counter")

Appliation的value属性

  例如:Application.value("counter")=1000  因为value可省略,故等效于 Application("counter")=1000 

----------------

Application对象有两个方法,都用于处理多个用户存储在Application中的数据进行写入问题。Lock和Unlock。

Lock:阻止其他客户修改村吃在application对象中的变量,以确保同一时刻仅一个客户可修改和存取application。

<%
Dim NumVisits=0
Application.LockApplication("NumVisits")=Application("NumVisits")+1
Application.Unlock
response.write "你是本站的第"&Application("NumVisits")&"访客"
%>

----------------

 Contents.Remove("NumVisits")  删除一个名为NumVisits的对象名

 Contents.RemoveAll()   删除全部的对象名

 

 第五章. ADO数据库编程 P96

use northwind
create procedure sp_countcustomer as
return(select count(*) from customers)
go

set mycomm=server.createobject("adodb.command")
with mycomm
 .activeconnection=conn
 .commandtext="sp_countcustomer"
 .commandtype=adcmdstoredproc
 '创建存储过程参数
 '获取存储过程参数的返回值,只需要createparameter的第3个参数为adparamreturnvalue就可以了
 set mypar=.createparameter("retval",adinteger,adparamreturnvalue) 
 '将创建的参数添加到数据库列表中
 .parameters.append mypar
 '因为不需要创建记录集,因此直接执行
 .execute()
end with
response.write "客户表中的总记录数为:"&mycomm.parameters("retval")
conn.close
set conn=nothing

 

posted on 2009-01-13 20:21  imwho  阅读(241)  评论(0编辑  收藏  举报

导航