<%
dim ObjConn,ConnStr,ObjRS,SqlStr
UserId = trim(request.form( "UserId "))
UserPwd= trim(request.form( "UserPwd "))
ConnStr= "provider=microsoft.jet.oledb.4.0;data source= " & _
server.mappath( "../db/sysm.mdb ")
set ObjConn= server.createObject( "adodb.connection ")
Objconn.open ConnStr
set ObjRS= server.createObject( "adodb.Recordset ")
SqlStr= "SELECT * FROM userifo where userid= ' " & userid & " ' and userpwd= ' " & userpwd & " ' "
Objrs.open SqlStr,Objconn,1,3
IF ObjRS.EOF THEN
Response.write " <center> 不存在此用户或密码错误! </center> "
ELSE IF UserId= "admin " then
session( "userId ")=UserId
session( "userpwd ")=UserPwd
session( "Passed ")=true
server.transfer( "adimn.asp ")
ELSE
session( "userId ")=UserId
session( "userpwd ")=UserPwd
session( "Passed ")=true
server.transfer( "commuser.asp ")
END IF
end if
ObjConn.close
ObjRs.close
'set Objconn = nothing
set ObjRS = nothing
加‘号的语句如果去掉’号之后,便会出现下面错误,请诸位大侠给看看。
错误类型:
ADODB.Recordset (0x800A0E78)
对象关闭时,不允许操作。
/myweb/log/app/logon.asp, 第 44 行
------解决方案--------------------
IF ObjRS.EOF or objRs.BOF THEN '不存在
.....
Else '存在
If UserId= "admin " then
......
else
. ......
end if
End IF
------解决方案--------------------
ObjConn.close
ObjRs.close
'set Objconn = nothing
set ObjRS = nothing
===============
你把位置搞反了...
这样写
ObjRs.close
set ObjRS = nothing
ObjConn.close
set Objconn = nothing