[求助]ASP程序有个问题
大家好,我刚刚学ASP,今天编了个留言本,但有时可以执行,有时却不行,真是怪事,请高手们帮下忙,谢谢。显示留言那部分代码没有问题,估计是添加记录时出了什么问题。
数据库各字段如下:
ID time ip message title email name qq homepage
自动编号 日期 文本 文本 文本 文本 文本 数字 文本
数据库名:post.mdb
<%
'-------------------------------------------------下面代码用于处理新留言----------------------
if request.Form("name")<>"" then
if request.Form("title")<>"" then
if request.Form("msg")<>"" then
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("post.mdb")
set rs1=server.CreateObject("adodb.recordset")
sqlstr1="select * from msg"
rs1.open sqlstr1,conn1,3,3
rs1.movelast
rs1.addnew
'------------------------------------------------向数据库中写入数据-----------------------------
rs1("qq")=request.Form("QQ")
rs1("email")=request.Form("email")
rs1("name")=request.Form("name")
rs1("homepage")=request.Form("homepage")
rs1("title")=request.Form("title")
rs1("message")=request.Form("msg")
rs1("time")=now()
dim userip
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip = Request.ServerVariables("REMOTE_ADDR")
end if
rs1("ip")=userip
rs1.update
rs1.close
conn1.close
set rs1=nothing
set conn1=nothing
response.redirect("index.asp")
end if
end if
end if
'-------------------------------------------------处理留言部分结束----------------------------
%>
'-------------------------------------------------下面代码用于处理新留言----------------------
if request.Form("name")<>"" then
if request.Form("title")<>"" then
if request.Form("msg")<>"" then
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("post.mdb")
set rs1=server.CreateObject("adodb.recordset")
sqlstr1="select * from msg"
rs1.open sqlstr1,conn1,3,3
rs1.movelast
rs1.addnew
'------------------------------------------------向数据库中写入数据-----------------------------
rs1("qq")=request.Form("QQ")
rs1("email")=request.Form("email")
rs1("name")=request.Form("name")
rs1("homepage")=request.Form("homepage")
rs1("title")=request.Form("title")
rs1("message")=request.Form("msg")
rs1("time")=now()
dim userip
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip = Request.ServerVariables("REMOTE_ADDR")
end if
rs1("ip")=userip
rs1.update
rs1.close
conn1.close
set rs1=nothing
set conn1=nothing
response.redirect("index.asp")
end if
end if
end if
'-------------------------------------------------处理留言部分结束----------------------------
%>
[此贴子已经被作者于2007-10-7 21:05:58编辑过]