Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to do an " if and" redirect 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I am trying to do a if and, redirect but I am getting and error
Code:
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement

what I would like is to check if a field is empty or not.

Here is what I have tried

Code:
<% if rs("itm") = rst1(("itm") and rs("uid") = rst1("uid") then response.redirect"in.asp" else "tryagain.asp"%>
 
You have an extra open parenthesis,you are missing an End If, and you are missing a response.redirect.

Code:
<% 
   if rs("itm") = rst1("itm") and rs("uid") = rst1("uid") Then 
      response.redirect"in.asp" 
   else 
      response.redirect "tryagain.asp"
   End If
%>


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I tried it but it still giving me an error. I think is because I don't have any records on the table for the rst1?
 
I think I will approach this a different way.

I have a log in page, and I know I can pass the login to another page like this
Code:
Username = Request.Form("txtUsername")
what I am not sure about is on the syntax for this
Code:
<% 
   if & Session(Username)& = rst1("username") Then 
      response.redirect("in.asp") 
   
   else
      response.redirect("tryagain.asp")
   End If
%>
 
Code:
<%
   if Session(Username) = rst1("username") Then
      response.redirect("in.asp")
   
   else
      response.redirect("tryagain.asp")
   End If
%>

This results in an error if rst1.eof is true.
So probably you must do this:
Code:
if not rst1.eof then
   if Session(Username) = rst1("username") Then
      response.redirect("in.asp")
   
   else
      response.redirect("tryagain.asp")
   End If
else
      response.redirect("tryagain.asp")
end if


Normally i close recordsets and connection before redirecting. I small UDF could help:
Code:
function Disconnect
 rst1.close
 conn.close
 set rst1 = nothing
 set conn = nothing
end function


if not rst1.eof then
   if Session(Username) = rst1("username") Then
      Disconnect()
      response.redirect("in.asp")
   
   else
      Disconnect()
      response.redirect("tryagain.asp")
   End If
else
      Disconnect()
      response.redirect("tryagain.asp")
end if

Depending on your situation you could improve this. I have my UDF's in an include file.




 
foxbox,

your suggestion kind of worked, it redirects me to the tryagain.asp but never to the in.asp

not sure why. I appreciate the help and suggestions.

Thanks
 
Code:
response.write "[" & Session(Username) & "]<br>"
response.write "[" & rst1("username") & "]"

(after if not rst1.eof then)

will tell you why i presume.


maybe you must trim() both fields, and maybe make the case te same (ucase())




 
I tried the code and got a
Code:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'rst1'

I took the
Code:
response.write "[" & rst1("username") & "]"
out and just left
Code:
response.write "[" & Session(Username) & "]<br>"

and got empty

Code:
[]

so it looks like my
Code:
Username = Request.Form("txtUsername")
is not working properly

so... back to the drawing board to see why I am not seeing my Request.Form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top