www.webdeveloper.com
Results 1 to 7 of 7

Thread: Response.redirect

  1. #1
    Join Date
    Dec 2002
    Location
    South Africa
    Posts
    12

    Exclamation Response.redirect

    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

  2. #2
    Join Date
    Feb 2003
    Posts
    28

    Re: Response.redirect

    Originally posted by Mac
    Code:
    	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

  3. #3
    Join Date
    Dec 2002
    Location
    South Africa
    Posts
    12
    no im referring to the reponse.redirect "Exists.htm" that is in BOLD, its the last line of code

  4. #4
    Join Date
    Feb 2003
    Posts
    28
    Since it's the same redirect as above, how do you know that it's getting to that line?

    Lin

  5. #5
    Join Date
    Dec 2002
    Location
    South Africa
    Posts
    12
    That was the first thing that i tested , because when i comment out the last response.redirect , the code works

  6. #6
    Join Date
    Feb 2003
    Posts
    28
    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

  7. #7
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    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.
    ----------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles