ASP Code Redirect Error SOS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dragiton
    New Member
    • Apr 2008
    • 12

    ASP Code Redirect Error SOS

    ASP Code Redirect Error

    Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have the following problem: any suggestions?

    I have a newuser login page that creates a new SQL DB table record with login name and password then takes the user to the next (page) step in the registration setup. Currently the record is created in the DB however the redirect doesn't occur. I get my asp message error (Msg = Msg & "An error occurred while creating the new account. " ) The following code is the newuser code:

    <%
    Option Explicit

    on error resume next

    Session("LoginN ame") = ""
    Session("NewUse r") = True

    dim adoCn
    dim adoRs
    dim SQL
    dim Msg
    dim TempChar
    dim I

    dim Account
    dim Password

    Account = trim(Request("t xtAccount"))
    Password = trim(Request("t xtPassword1"))

    Msg = ""

    if len(Account) < 6 then
    Msg = Msg & "The account name must be at least 6 characters long.<br>"
    end if

    if len(Password) < 6 then
    Password = ""
    Msg = Msg & "The password must be at least 6 characters long.<br>"
    end if

    for I = 1 to len(Account)
    TempChar = asc(ucase(mid(A ccount, I , 1)))

    if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
    Msg = Msg & "The account name you entered is invalid. "
    Msg = Msg & "Please use only letters or numbers.<br>"
    exit for
    end if
    next

    for I = 1 to len(Password)
    TempChar = asc(ucase(mid(P assword, I , 1)))

    if (((TempChar >= 48) and (TempChar <= 57)) or ((TempChar >= 65) and (TempChar <= 90))) = False then
    Password = ""
    Msg = Msg & "The password you entered is invalid. "
    Msg = Msg & "Please use only letters or numbers.<br>"
    exit for
    end if
    next

    if (Account <> "") and (Password <> "") then
    if Password <> trim(Request("t xtPassword2")) then
    Msg = Msg & "The retyped password is different than the first. "
    Msg = Msg & "Please confirm the password.<br>"
    else
    SQL = "select * from tbRegistration "
    SQL = SQL & "where (LoginName like '" & Account & "');"

    set adoCn = Server.CreateOb ject("ADODB.Con nection")
    adoCn.Open Session("SQLCon nect")

    set adoRs = Server.CreateOb ject("ADODB.Rec ordset")
    adoRs.Open SQL, adoCn, 1, 3

    if adoRs.EOF then
    adoRs.AddNew
    adoRs("LoginNam e") = Account
    adoRs("LoginPas sword") = Password
    adoRs("DateRegi stered") = Date
    adoRs("IsAdmin" ) = False
    adoRs("RenewalA mount") = Session("Amount ")
    adoRs.Update
    else
    Msg = Msg & "The account name you selected is already in use. "
    Msg = Msg & "Please select another account name.<br>"
    end if

    adoRs.Close
    adoCn.Close

    set adoRs = Nothing
    set adoCn = Nothing

    if Err.Number <> 0 then
    Err.Clear
    Msg = Msg & "An error occurred while creating the new account. "
    Msg = Msg & "Please try again.<br>"
    end if

    if Msg = "" then
    Session("LoginN ame") = Account
    Response.Redire ct("memreg.asp? mode=update")
    Response.End
    end if
    end if
    end if
    %>
    <html>

    <head>
    <title>New Member Account</title>
    <meta name="Microsoft Border" content="l">
    </head>


    <form name="frmPost" method="POST" action="newuser .asp" onSubmit="retur n(Validate());" >
    <table>
    <tr>
    <td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Acc ount Name:</b><br><i>(6 chars minimum)</i></font></td>
    <td valign="top" align="left" nowrap><input type="text" name="txtAccoun t" size="20" maxlength="20" value="<% =Account %>"></td>
    </tr>
    <tr>
    <td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Pas sword:</b><br><i>(6 chars minimum)</i></font></td>
    <td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd1" size="20" maxlength="20" value="<% =Password %>"></td>
    </tr>
    <tr>
    <td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Ret ype Password:</b><br><i>(6 chars minimum)</i></font></td>
    <td valign="top" align="left" nowrap><input type="password" name="txtPasswo rd2" size="20" maxlength="20"> </td>
    </tr>
    </table>
    <p><input type="submit" value="Next" name="btnNext"> </p>
    </form>

    <p><font face="Arial" size="2"><% =Msg %></font></p>

    </td></tr>

    </table>


    </html>
    <script LANGUAGE="javas cript">
    <!--
    function Validate() {
    if (document.frmPo st.txtAccount.v alue.length < 6) {
    alert("The account name must be at least 6 characters long.");
    document.frmPos t.txtAccount.fo cus();
    document.frmPos t.txtAccount.se lect();
    return false;
    }
    if (!ValidateValue (document.frmPo st.txtAccount.v alue)) {
    alert("The account name is invalid. Please enter only letters or numbers.");
    document.frmPos t.txtAccount.fo cus();
    document.frmPos t.txtAccount.se lect();
    return false;
    }
    if (document.frmPo st.txtPassword1 .value.length < 6) {
    alert("The password must be at least 6 characters long.");
    document.frmPos t.txtPassword1. focus();
    document.frmPos t.txtPassword1. select();
    return false;
    }
    if (!ValidateValue (document.frmPo st.txtPassword1 .value)) {
    alert("The password is invalid. Please enter only letters or numbers.");
    document.frmPos t.txtPassword1. focus();
    document.frmPos t.txtPassword1. select();
    return false;
    }
    if (document.frmPo st.txtPassword1 .value != document.frmPos t.txtPassword2. value) {
    alert("The retyped password does not match the first one.");
    document.frmPos t.txtPassword2. focus();
    document.frmPos t.txtPassword2. select();
    return false;
    }

    return true;
    }

    function ValidateValue(I nputValue) {
    var ValidChars = "ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz0123456 789";
    var IsValid = true;
    var CheckChar;

    for (var i=0; i < InputValue.leng th; i++) {
    CheckChar = "" + InputValue.subs tring(i, i+1);
    if (ValidChars.ind exOf(CheckChar) == "-1") IsValid = false;
    }

    return IsValid;
    }
    -->
    </script>



    thanks,

    dragiton
    drag.it.on@hotm ail.com
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    get rid of the "on error resume next" and find out what line is having the problem and what the actual error message is.

    Comment

    • dragiton
      New Member
      • Apr 2008
      • 12

      #3
      OK after removing the on error resume next line I get the following error:

      ADODB.Recordset error '800a0cc1'

      Item cannot be found in the collection corresponding to the requested name or ordinal.

      /newuser.asp, line 73

      And line 73 of the newuser page is the adoRs(RenewalAm ount) line as follows:

      if adoRs.EOF then
      adoRs.AddNew
      adoRs("LoginNam e") = Account
      adoRs("LoginPas sword") = Password
      adoRs("DateRegi stered") = Date
      adoRs("IsAdmin" ) = False
      adoRs("RenewalA mount") = Session("Amount ")
      adoRs.Update
      else
      Msg = Msg & "The account name you selected is already in use. "
      Msg = Msg & "Please select another account name.<br>"
      end if



      any suggestions?? ??????

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Hi there,

        This error means that the specified column (in this case RenewalAmount) cannot be found in the selected table (in this case tbRegistration) .

        You'll need to check the database for the following:

        Does the column RenewalAmount actually exist in the table tbRegistration?

        Does the name RenewalAmount exactly match the name of the column in the database?

        Let me know how you get on,

        Dr B

        Comment

        • dragiton
          New Member
          • Apr 2008
          • 12

          #5
          thanks so much that was it. I relaunched the website after both the DB and Site had been updated with new functionality. I didn't realize that was the case until now. I will just need to go through and update the DB to match the functionality now.

          Thanks again.

          Comment

          • dragiton
            New Member
            • Apr 2008
            • 12

            #6
            I wrote that wrong, the site DB was restored from a 2001 version of data. And the website files had updates from 2005. Thanks again.

            Comment

            • DrBunchman
              Recognized Expert Contributor
              • Jan 2008
              • 979

              #7
              No problem, glad to be of help.

              Dr B

              Comment

              Working...