ASP读取数据库房刷新快了要出错
<%nm=cstr(request.form("name"))pwd=cstr(request.form("pwd"))setconn=server.createobje...
<%
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "用户名或密码错误"
conn.close
set conn=nothing
%>
第一次运行会显示“用户名或密码错误”
但返回再进就会出现Provider (0x80004005)
如何解决刷新快了不出错! 展开
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "用户名或密码错误"
conn.close
set conn=nothing
%>
第一次运行会显示“用户名或密码错误”
但返回再进就会出现Provider (0x80004005)
如何解决刷新快了不出错! 展开
1个回答
展开全部
<%
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "用户名或密码错误"
end if
'你在这里缺少了end if来结束if,或使用else...end if也行,总之要结束if.也有不使用end if的方法,就需要把if then 内容写在一起,如
if rs.eof then response.write "用户名密码错误"
conn.close
set conn=nothing
'---------------------------------------------------------
'另外,你可能需要重定向到登陆页面,建议用Response.Redirect进行页面输出:Response.Redirect "login.asp"
因此你的语句可以这样写:
'---------------------------------------------------------
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "<script language=JavaScript>{window.alert('登陆失败,用户名或密码错!');window.location.href='login.asp'}</script>"
else
session("username")=nm
'进行session设置后页面转向
Response.Redirect "main.asp"
end if
conn.close
set conn=nothing
%>
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "用户名或密码错误"
end if
'你在这里缺少了end if来结束if,或使用else...end if也行,总之要结束if.也有不使用end if的方法,就需要把if then 内容写在一起,如
if rs.eof then response.write "用户名密码错误"
conn.close
set conn=nothing
'---------------------------------------------------------
'另外,你可能需要重定向到登陆页面,建议用Response.Redirect进行页面输出:Response.Redirect "login.asp"
因此你的语句可以这样写:
'---------------------------------------------------------
nm=cstr(request.form("name"))
pwd=cstr(request.form("pwd"))
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("wm.mdb")
set rs=server.createobject("adodb.recordset")
exec="select * from user where name='"&nm&"'"
rs.open exec,conn,1,1
if rs.eof then
response.write "<script language=JavaScript>{window.alert('登陆失败,用户名或密码错!');window.location.href='login.asp'}</script>"
else
session("username")=nm
'进行session设置后页面转向
Response.Redirect "main.asp"
end if
conn.close
set conn=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询