Help with Code to work! ASP , SQL

I'm still new to all of this! But hopefully someone can help out

I'm trying to get this AND statement to work.
It's getting the variablies across, but I can't see
what I'm doing wrong. Can't get the Redirect to work.



Companyidnumber =  TRIM(rs1("company_id"))
   Cergo = TRIM(rs1("ergo"))
   
   response.write(Cergo)
   response.write(Companyidnumber)
   
    IF NOT rs1.EOF = true & Cergo = False then  
                        
      'record was returned, good login!'
         Session("UID") = userid      
         Response.Redirect ("entryform.asp")      
       Response.End
 
   End IF
   
   else
   
     response.write("I'm here in this branch")
   
   
   
  end if
 

Any help will be grateful

d.
DstathakisAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
Should the & be && asit is in C or C++?

mlmcc
0
mlmccCommented:
IF NOT rs1.EOF = true & Cergo = False then  

Since you are already comparing booleans

rs1.EOF = TRUE is true when rs1.eof is true

Try this

If (Not rs1.EOF) && (Not Cergo) then

mlmcc
0
DstathakisAuthor Commented:
Thank you it  help me out. Next how would I say the oppose.

 Companyidnumber =  TRIM(rs1("company_id"))
  Cergo = TRIM(rs1("ergo"))
   
   response.write(Cergo)
   response.write(Companyidnumber)
   
         If (Not rs1.EOF) And (Not Cergo) then
                          
            'record was returned, good login!'
              Session("UID") = userid    
              Response.Redirect ("entryform.asp")    
             Response.End

      'I need need it not to be right so the user will be redirect somewhere else?

        If (Not rs1.EOF) And (Not Cergo) then
                          
            'record was returned, good login!'
              Session("UID") = userid    
              Response.Redirect ("queryform.asp")    
             Response.End
   
   else
   
     response.write("I'm here in this branch")
   
   
   end if
   end if
 end if

d.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

mlmccCommented:
Try this
        If (rs1.EOF) OR (Cergo) then

mlmcc
0
DstathakisAuthor Commented:
I missed comunicated what I was needing! I need to have the first part of this
statement true but the second part false.

I tried changing it around but I missed!

If (Not rs1.EOF) or (Cergo) then

d.
0
mlmccCommented:
I don't follow.  What are you trying to test for?

What does rs1.EOF indicate when it is TRUE?

What does Cergo indicate when it is TRUE?

mlmcc
0
DstathakisAuthor Commented:
I'm doing a secruity check if the user password and id pan out then rs1.EOF comes back true I'm also checking another field and depending on who the user is, will return true or false. This in return will direct them to the right ASP page I set-up.

Hope this makes sense.

 
0
mlmccCommented:
there are four possible combinatiions to test

 If (Not rs1.EOF) And (Not Cergo) then
         
 else If (Not rs1.EOF) And (Cergo) then

 else If (rs1.EOF) And (Not Cergo) then

 else if (rs1.EOF) And (Cergo) then

 else ERROR

Think through what each combination means then determine where the user should go.

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DstathakisAuthor Commented:
thanks you've been alot of help!
0
DstathakisAuthor Commented:
I'm running into one final error!
Can you help!

Here's what I getting as an Error Message:

Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Below is the code I'm running it's bombing on the last else statment. It states the error is
happening on line 35 which is Cergo = rs1("ergo")

Hope I make sense

d.



 IF LEN(userid) <> 0 AND LEN(pwd) <> 0 Then

   strSQL=  "SELECT * "                              &_
            "  FROM users "                        &_
          " WHERE uid = '" & userid & "'"         &_
          "   AND password = '" & pwd & "'"  
            
                        
   SET rs1 = Objconn.execute(strSQL)
   
    Cergo = rs1("ergo")
      
      '*****This statement will only pass if the users password and ID are correct'
      '*****Back True and the user is NOT an Employee of Ergo '

         If (Not rs1.EOF) And (Not Cergo) then
          
              Companyidnumber = rs1("company_id")
                        
             Session("UID") = userid    
            Response.Redirect ("entryform.asp")    
           Response.End
     
 
      
  '*****This statment will only work if Ergo Employee'
  '*****Has entered the statement and correct Password and ID'
 
      else If (Not rs1.EOF) And (Cergo) then            
         Companyidnumber = rs1("company_id")
        
         Companyidnumber =  " "
       Session("UID") = userid    
         Response.Redirect ("queryform.asp")    
         Response.End
         
 
   '*****This statment WILL NOT pass anyone'
   '****Because password and ID are incorrect'
   
   Else  
   
 
    response.write("I'm here")
 

            
      
    End IF
    End IF
    End IF
 

 
 %>
0
mlmccCommented:
The recordset didn't open correctly.

How is it declared?

mlmcc
0
DstathakisAuthor Commented:
Sorry, I was finally able to figure it out.

0
mlmccCommented:
Glad I could help

mlmcc
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.