|
 |
access_asp thread: redirect for bad password fails
Message #1 by "Andy Wischmann" <andy@9...> on Tue, 6 Aug 2002 20:05:49 -0700
|
|
The redirect when a correct username and password are entered works fine.
The redirect when an incorrect username or password creates the following error:
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/login/ProcessLogin.asp, line 23
Thanks for any help.
--------------------------------------------------------------------------
<%@ Language=VBScript %>
<%Response.Buffer=true%>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 5.0">
</HEAD>
<BODY>
<%
Dim conn,rs,strsql
set conn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
'DSN less connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & Server.MapPath("login.mdb")
conn.open
strsql = "Select Username, Password, Group From Login where Username = '" & _
Request.Form("txtusername") & "' and Password = '" & _
Request.Form("txtpassword") & "'"
set rs = conn.Execute (strsql)
group=rs.Fields("Group")
If (not rs.BOF) and (not rs.EOF) then
Response.Cookies("Username") = rs.Fields("Username")
Response.Redirect("http://99.99.99.87/" + group)
else
Response.Redirect "http://99.99.99.87/asplogin/badpassword.htm"
end if
'close the recordset
rs.close
set rs = nothing
'close the connection
conn.close
set conn = nothing
%>
</script>
</BODY></HTML>
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 7 Aug 2002 15:10:18 +1000
|
|
You need to do this line:
<% group=rs.Fields("Group") %>
*after* you test for .EOF At the moment you have:
<%
: group=rs.Fields("Group")
:
: If (not rs.BOF) and (not rs.EOF) then
: Response.Cookies("Username") = rs.Fields("Username")
: Response.Redirect("http://99.99.99.87/" + group)
: else
: Response.Redirect "http://99.99.99.87/asplogin/badpassword.htm"
: end if
%>
What you need is:
<%
If (not rs.BOF) and (not rs.EOF) then
group=rs.Fields("Group")
Response.Cookies("Username") = rs.Fields("Username")
strRedirectURL = "http://99.99.99.87/" + group
Else
strRedirectURL = "http://99.99.99.87/asplogin/badpassword.htm"
End if
' ------------------------------------------------------------
' --- NOW CLEAN UP YOUR OBJECTS!!!
' ------------------------------------------------------------
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
' ------------------------------------------------------------
' --- NOW DO THE REDIRECT
' ------------------------------------------------------------
Response.Redirect(strRedirectURL)
%>
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
----- Original Message -----
From: "Andy Wischmann" <andy@9...>
To: "Access ASP" <access_asp@p...>
Sent: Wednesday, August 07, 2002 1:05 PM
Subject: [access_asp] redirect for bad password fails
: The redirect when a correct username and password are entered works fine.
:
: The redirect when an incorrect username or password creates the following
error:
: Error Type:
: ADODB.Field (0x800A0BCD)
: Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
: /login/ProcessLogin.asp, line 23
:
:
:
: Thanks for any help.
: --------------------------------------------------------------------------
:
: <%@ Language=VBScript %>
: <%Response.Buffer=true%>
: <HTML><HEAD>
: <META NAME="GENERATOR" Content="Microsoft FrontPage 5.0">
: </HEAD>
: <BODY>
:
: <%
: Dim conn,rs,strsql
: set conn = server.CreateObject("ADODB.Connection")
: set rs = server.CreateObject("ADODB.Recordset")
:
: 'DSN less connection
: conn.Provider = "Microsoft.Jet.OLEDB.4.0"
: conn.ConnectionString = "Data Source=" & Server.MapPath("login.mdb")
: conn.open
:
: strsql = "Select Username, Password, Group From Login where Username = '"
& _
: Request.Form("txtusername") & "' and Password = '" & _
: Request.Form("txtpassword") & "'"
: set rs = conn.Execute (strsql)
:
: group=rs.Fields("Group")
:
: If (not rs.BOF) and (not rs.EOF) then
: Response.Cookies("Username") = rs.Fields("Username")
: Response.Redirect("http://99.99.99.87/" + group)
: else
: Response.Redirect "http://99.99.99.87/asplogin/badpassword.htm"
: end if
:
:
: 'close the recordset
: rs.close
: set rs = nothing
:
: 'close the connection
: conn.close
: set conn = nothing
:
: %>
:
: </script>
:
: </BODY></HTML>
:
:
|
|
 |