最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp保存数据到access数据库代码
时间:2010-10-24 编辑:简简单单 来源:一聚教程网
数据库连接代码
<%
dbname="chatroom.mdb"
set conn=server.createobject("adodb.connection")
connstr="dbq="+server.mappath(dbname)+";driver={microsoft access driver (*.mdb)};"
conn.open connstr
%>
html页面代码
postmsg
处理页面可保存在同一页面
<%
ac=request.querystring("act") '读取act 的值
if ac="addmsg" then 'act的值为addmsg
if request.form("hidden")<>"" then '私聊
session("chat")="" '清空session("chat")中的内容
'把要显示的私聊信息保存在application("chat")中
application("chat")=""&request.form("username")&"悄悄地对"&request.form("rname")&"说:"&request.form("msg")&""&time()&""
application("chatto")=request.form("rname") '聊天对象
application("owner")=request.form("username") '发言者
else '不是私聊
set rs=server.createobject("adodb.recordset") '创建recordset对象
sql="select * from chat" '查询数据库
rs.open sql,conn,1,3 '执行查询
rs.addnew '添加一条新记录
rs("fromname")=request.form("username") '发言者
rs("toname")=request.form("rname") '聊天对象
rs("chat")=request.form("msg") '显示的私聊信息
rs("posttime")=time() '提交时间
rs.update
rs.close
set rs=nothing
'增加一条聊天记录,将application("gchatnum")的值加1
application("gchatnum")=application("gchatnum")+1
end if
end if
%>源码下载地址
-
上一个: asp access入门级数据库连接文件
-
下一个: asp access用户注册实例
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14