请高手帮我一下asp数据库连接问题
技术信息(用于支持人员)
错误类型:
Microsoft VBScript 运行时错误 (0x800A000D)
类型不匹配: 'rs '
/jiaoyi/userLogin.asp, 第 24 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
网页:
POST 42 ??? /jiaoyi/userLogin.asp
POST Data:
UserName=1&Password=1&Login=+%B5%C7%C2%BC+
代码为 :
<%
'username=request( "username ")
'password=request( "password ")
username=replace(trim(request( "username ")), " ' ", " ")
password=replace(trim(Request( "password ")), " ' ", " ")
call dbconnect()
'sql= "select *from [use] where nam= "&username
sql= "select * from [use] where nam= ' " & username & " ' "
'response.write sql
'response.end
call openrs(sql,rs,2)
do while not rs.eof
if password=rs( "pwd ") and username=rs( "nam ") then
flag=1
else
flag=0
end if
rs.movenext
loop
rs.close
set rs=nothing
if flag=1 then
Session( "usernam ")=rs( "nam ")
response.redirect "index.asp "
end if
if flag=0 then
%>
------解决方案--------------------if password=cstr(Trim(rs( "pwd "))) and username=cstr(rs( "nam ")) then
------解决方案--------------------你都rs.close了,下面再调用,不出错就难了...分是低了点,不过...算了,改成下面这样就可以了
<%
'username=request( "username ")
'password=request( "password ")
username=replace(trim(request( "username ")), " ' ", " ")
password=replace(trim(Request( "password ")), " ' ", " ")
call dbconnect()
'sql= "select *from [use] where nam= "&username
sql= "select * from [use] where nam= ' " & username & " ' "
'response.write sql
'response.end
call openrs(sql,rs,2)
do while not rs.eof
if password=rs( "pwd ") and username=rs( "nam ") then
flag=1
else
flag=0
end if
rs.movenext
loop
if flag=1 then
Session( "usernam ")=rs( "nam ")
response.redirect "index.asp "
end if
if flag=0 then
%>
------解决方案--------------------rs.close错误1
set rs=nothing
if flag=1 then
Session( "usernam ")=rs( "nam ")上面close了关闭了数据库,就没办法用了
response.redirect "index.asp "
end if
if flag=0 then错误2这里少end if