469,950 Members | 2,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

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("LoginName") = ""
Session("NewUser") = True

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

dim Account
dim Password

Account = trim(Request("txtAccount"))
Password = trim(Request("txtPassword1"))

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(Account, 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(Password, 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("txtPassword2")) 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.CreateObject("ADODB.Connection")
adoCn.Open Session("SQLConnect")

set adoRs = Server.CreateObject("ADODB.Recordset")
adoRs.Open SQL, adoCn, 1, 3

if adoRs.EOF then
adoRs.AddNew
adoRs("LoginName") = Account
adoRs("LoginPassword") = Password
adoRs("DateRegistered") = Date
adoRs("IsAdmin") = False
adoRs("RenewalAmount") = 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("LoginName") = Account
Response.Redirect("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="return(Validate());">
<table>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Account Name:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="text" name="txtAccount" size="20" maxlength="20" value="<% =Account %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Password:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPassword1" size="20" maxlength="20" value="<% =Password %>"></td>
</tr>
<tr>
<td valign="top" align="left" nowrap><font face="Arial" size="2"><b>Retype Password:</b><br><i>(6 chars minimum)</i></font></td>
<td valign="top" align="left" nowrap><input type="password" name="txtPassword2" 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="javascript">
<!--
function Validate() {
if (document.frmPost.txtAccount.value.length < 6) {
alert("The account name must be at least 6 characters long.");
document.frmPost.txtAccount.focus();
document.frmPost.txtAccount.select();
return false;
}
if (!ValidateValue(document.frmPost.txtAccount.value) ) {
alert("The account name is invalid. Please enter only letters or numbers.");
document.frmPost.txtAccount.focus();
document.frmPost.txtAccount.select();
return false;
}
if (document.frmPost.txtPassword1.value.length < 6) {
alert("The password must be at least 6 characters long.");
document.frmPost.txtPassword1.focus();
document.frmPost.txtPassword1.select();
return false;
}
if (!ValidateValue(document.frmPost.txtPassword1.valu e)) {
alert("The password is invalid. Please enter only letters or numbers.");
document.frmPost.txtPassword1.focus();
document.frmPost.txtPassword1.select();
return false;
}
if (document.frmPost.txtPassword1.value != document.frmPost.txtPassword2.value) {
alert("The retyped password does not match the first one.");
document.frmPost.txtPassword2.focus();
document.frmPost.txtPassword2.select();
return false;
}

return true;
}

function ValidateValue(InputValue) {
var ValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789";
var IsValid = true;
var CheckChar;

for (var i=0; i < InputValue.length; i++) {
CheckChar = "" + InputValue.substring(i, i+1);
if (ValidChars.indexOf(CheckChar) == "-1") IsValid = false;
}

return IsValid;
}
-->
</script>



thanks,

dragiton
drag.it.on@hotmail.com
Apr 7 '08 #1
6 2119
danp129
321 Expert 100+
get rid of the "on error resume next" and find out what line is having the problem and what the actual error message is.
Apr 7 '08 #2
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(RenewalAmount) line as follows:

if adoRs.EOF then
adoRs.AddNew
adoRs("LoginName") = Account
adoRs("LoginPassword") = Password
adoRs("DateRegistered") = Date
adoRs("IsAdmin") = False
adoRs("RenewalAmount") = 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?? ??????
Apr 9 '08 #3
DrBunchman
979 Expert 512MB
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
Apr 9 '08 #4
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.
Apr 10 '08 #5
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.
Apr 10 '08 #6
DrBunchman
979 Expert 512MB
No problem, glad to be of help.

Dr B
Apr 10 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Bob Garbados | last post: by
10 posts views Thread by Spam Bill Gates | last post: by
2 posts views Thread by Kerri | last post: by
3 posts views Thread by Bishoy George | last post: by
6 posts views Thread by Sam | last post: by
6 posts views Thread by Nick Horrocks | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.