求asp+access 计数器 代码实例

来源:百度知道 编辑:UC知道 时间:2024/07/07 18:48:53
麻烦会的人给出完整的代码和注释
access数据库名 表名 变量命都可以于注释
数据库的建立过程也说明一下吧
asp文本计数器已经有了,别再发了

<%
//先建一个表counter,字段hits(int),并插入一条数据hits=0
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("cou.mdb") //cou是数据库名
conn.open connstr
if session("visited")<>"yes" then
application.Lock()
conn.execute("update counter set hits=hits+1") //counter是数据库里面用于存储数据的表名
application.UnLock()
session("visited")="yes"
end if
set rs=conn.execute("select * from counter")
if rs.eof and rs.bof then
counters=0
else
counters=rs("hits")
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write counters
%>

你是做网站?采纳后细说。