Click to See Complete Forum and Search --> : Response.redirect


Mac
02-09-2003, 10:29 AM
Here is my code:

<CODE>
rsAccCode.MoveFirst
Do until rsAccCode.EOF
if rsAccCode.Fields("AccessCodes").Value=x_AccCode then

' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str


Set objRS = Server.CreateObject("ADODB.Recordset")

SQL= "SELECT Username,AccCode,EmailAddress FROM tblUsers"
Set objRS =conn.Execute (SQL)

strUsername = Request.Form("x_Username")
strAccCode = Request.Form("x_AccCode")
strEmail = Request.Form("x_EmailAddress")

Do While Not objRs.EOF
if objRS("Username")=strUsername Then
Response.redirect "exists.htm"
Elseif objRS("AccCode")= strAccCode then
Response.redirect "exists.htm"
Elseif objRS("EmailAddress")=strEmail then
Response.redirect "exists.htm"
End if
objRS.MoveNext
Loop


Select Case a
Case "A": ' Add

' Open record
strsql = "SELECT * FROM [tblUsers] WHERE 0 = 1"

set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2

rs.AddNew


tmpFld = Trim(x_Username)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Username") = tmpFld
tmpFld = Trim(x_AccCode)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccCode") = tmpFld
tmpFld = Trim(x_FirstName)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("FirstName") = tmpFld
tmpFld = Trim(x_Surname)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Surname") = tmpFld
tmpFld = Trim(x_School)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("School") = tmpFld
tmpFld = Trim(x_Grade)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("Grade") = tmpFld
tmpFld = Trim(x_EmailAddress)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("EmailAddress") = tmpFld
tmpFld = Trim(x_AccessLevel)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("AccessLevel") = tmpFld
tmpFld = x_Date
If IsDate(tmpFld) Then
rs("Date") = cDate(tmpFld)
Else
rs("Date") = Null
End If
tmpFld = x_ExpiryDate
If IsDate(tmpFld) Then
rs("ExpiryDate") = cDate(tmpFld)
Else
rs("ExpiryDate") = Null
End If
rs.Update
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear
Response.Redirect "successreg.htm"
End Select

Response.End
end if

rsAccCode.MoveNext
loop

Response.redirect "exists.htm"
</CODE>

My problem is that the code wont run , because it goes directly to the 'Response.redirect "exists.htm"' , please can someone help me ive tried everything .

Thanks

linnie
02-09-2003, 10:32 AM
Originally posted by Mac

Do While Not objRs.EOF
if objRS("Username")=strUsername Then
Response.redirect "exists.htm"
Elseif objRS("AccCode")= strAccCode then
Response.redirect "exists.htm"
Elseif objRS("EmailAddress")=strEmail then
Response.redirect "exists.htm"
End if
objRS.MoveNext
Loop

Is this the part of the code you're referring to?

Lin

Mac
02-09-2003, 10:49 AM
no im referring to the reponse.redirect "Exists.htm" that is in BOLD, its the last line of code

linnie
02-09-2003, 10:53 AM
Since it's the same redirect as above, how do you know that it's getting to that line?

Lin

Mac
02-09-2003, 10:58 AM
That was the first thing that i tested , because when i comment out the last response.redirect , the code works

linnie
02-09-2003, 11:09 AM
I'm sorry if my short answers seem rude, but I just don't have enough information to give you more than that. And my response this time is: then what is the last redirect there for?

Lin

Ribeyed
02-09-2003, 12:21 PM
hi,
the reason its redirecting to exists.htm is becuse that is what your telling it to do.
As far as i can see with your code, this line:

Response.redirect "exists.htm"

will allways run regardless of the code above, so there is no error.