Skip navigation
ngovanhinh
Currently Being Moderated

Login redirect page error

Jan 8, 2013 8:18 PM

After login success or logout from my current page (i.e. "ic_detail.asp?ID=372", this page gets a variable from another page), it failed to redirect to that current page . I got the following error:

 

There is a problem with the page you are trying to reach and it cannot be displayed.

...


Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/idc/asp/ic_detail.asp, line 266

 

Here is the page code invovled:

 

 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%

' *** Logout the current user.

MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"

If (CStr(Request("MM_Logoutnow")) = "1") Then

  Session.Contents.Remove("MM_Username")

  Session.Contents.Remove("MM_UserAuthorization")

  MM_logoutRedirectPage = Request.ServerVariables("URL")

  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).

  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))

  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then

    MM_newQS = "?"

    For Each Item In Request.QueryString

      If (Item <> "MM_Logoutnow") Then

        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"

        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))

      End If

    Next

    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS

  End If

  Response.Redirect(MM_logoutRedirectPage)

End If

%>

<!--#include file="../Connections/cosodulieu.asp" -->

<!--#include file="../Connections/login.asp" -->

<%

Dim Mydoc__MMColParam

Mydoc__MMColParam = "1"

If (Request.QueryString("ID") <> "") Then

  Mydoc__MMColParam = Request.QueryString("ID")

End If

%>

<%

Dim Mydoc

Dim Mydoc_cmd

Dim Mydoc_numRows

 

Set Mydoc_cmd = Server.CreateObject ("ADODB.Command")

Mydoc_cmd.ActiveConnection = MM_cosodulieu_STRING

Mydoc_cmd.CommandText = "SELECT * FROM Incoming WHERE ID = ?"

Mydoc_cmd.Prepared = true

Mydoc_cmd.Parameters.Append Mydoc_cmd.CreateParameter("param1", 5, 1, -1, Mydoc__MMColParam) ' adDouble

 

Set Mydoc = Mydoc_cmd.Execute

Mydoc_numRows = 0

%>

<%

Dim rsuserdata__MMColParam

rsuserdata__MMColParam = "1"

If (Session("MM_Username") <> "") Then

  rsuserdata__MMColParam = Session("MM_Username")

End If

%>

<%

Dim rsuserdata

Dim rsuserdata_cmd

Dim rsuserdata_numRows

 

Set rsuserdata_cmd = Server.CreateObject ("ADODB.Command")

rsuserdata_cmd.ActiveConnection = MM_login_STRING

rsuserdata_cmd.CommandText = "SELECT * FROM login WHERE username = ?"

rsuserdata_cmd.Prepared = true

rsuserdata_cmd.Parameters.Append rsuserdata_cmd.CreateParameter("param1", 200, 1, 50, rsuserdata__MMColParam) ' adVarChar

 

Set rsuserdata = rsuserdata_cmd.Execute

rsuserdata_numRows = 0

%>

<%

' *** Validate request to log in to this site.

MM_LoginAction = Request.ServerVariables("URL")

If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)

MM_valUsername = CStr(Request.Form("txtusername"))

If MM_valUsername <> "" Then

  Dim MM_fldUserAuthorization

  Dim MM_redirectLoginSuccess

  Dim MM_redirectLoginFailed

  Dim MM_loginSQL

  Dim MM_rsUser

  Dim MM_rsUser_cmd

 

  MM_fldUserAuthorization = ""

  MM_redirectLoginSuccess = Request.ServerVariables("URL")

  MM_redirectLoginFailed = Request.ServerVariables("URL")

 

  MM_loginSQL = "SELECT username, pass"

  If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization

  MM_loginSQL = MM_loginSQL & " FROM login WHERE username = ? AND pass = ?"

  Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")

  MM_rsUser_cmd.ActiveConnection = MM_login_STRING

  MM_rsUser_cmd.CommandText = MM_loginSQL

  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 50, MM_valUsername) ' adVarChar

  MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 50, Request.Form("txtpassword")) ' adVarChar

  MM_rsUser_cmd.Prepared = true

  Set MM_rsUser = MM_rsUser_cmd.Execute

 

  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then

    ' username and password match - this is a valid user

    Session("MM_Username") = MM_valUsername

    If (MM_fldUserAuthorization <> "") Then

      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)

    Else

      Session("MM_UserAuthorization") = ""

    End If

    if CStr(Request.QueryString("accessdenied")) <> "" And false Then

      MM_redirectLoginSuccess = Request.QueryString("accessdenied")

    End If

    MM_rsUser.Close

    Response.Redirect(MM_redirectLoginSuccess)

  End If

  MM_rsUser.Close

  Response.Redirect(MM_redirectLoginFailed)

End If

%>

 

....

 

<h2>CHI TIẾT VĂN BẢN</h2>

<table width="800" border="0">

  <tr>

    <td width="162" class="Head">ID:</td>

    <td colspan="2" class="body"><%=(Mydoc.Fields.Item("ID").Value)%></td> ' Line 266 is here

    </tr>

  <tr>

 

Please help me to modify the code to redirect to my current page after login or logout.

 

Thanks

 
Replies
  • Currently Being Moderated
    Jan 9, 2013 10:50 AM   in reply to ngovanhinh

    The error means your recordset is empty.

    You are setting the redirect url here:

    MM_redirectLoginSuccess = Request.ServerVariables("URL")

    That only gives the base url. You need to append the existing query string.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points