日期:2014-05-17  浏览次数:20821 次

这段登陆代码错在哪里?
<!--#include   file= "../inc/conn.asp "-->
<%
'定义变量
dim   sql
dim   rs
dim   username
dim   password

'取得表单数据
username=trim(request( "username "))
password=trim(Request( "password "))

'定义recordset对象变量,由rs引用
set   rs=server.createobject( "adodb.recordset ")

'查询数据库
sql= "select   *   from   User   where   username= ' "   &   username   &   " '   and   password= ' "   &   password   & " ' "

'打开记录集
rs.open   sql,conn,1,1

'这里是判断
if   not(rs.bof   and   rs.eof)   then
                  '这个是不是判断是否找到有符合记录,0表是否
if   rs.recordcount=0   then
                          '没有就跳到错误,这个调用过程加不加 "() "
          call   pserror()
end   if
session( "UserName ")=username     '如果有就存储变量username
Response.Redirect   "index.asp "   '跳转

end   if

rs.close
conn.close
set   rs=nothing
set   conn=nothing
%>

问题是   他好象没有去查询数据库直接就跳到了 "index.asp "
在线求解?

------解决方案--------------------
你的conn.asp里是不是有on error resume next?