Solved

Help with Code to work!  ASP , SQL

Posted on 2003-11-25
13
384 Views
Last Modified: 2010-04-17
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.
0
Comment
Question by:Dstathakis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 9822265
Should the & be && asit is in C or C++?

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9822270
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
 

Author Comment

by:Dstathakis
ID: 9822363
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

Expert Comment

by:mlmcc
ID: 9822367
Try this
        If (rs1.EOF) OR (Cergo) then

mlmcc
0
 

Author Comment

by:Dstathakis
ID: 9822390
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 9822442
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
 

Author Comment

by:Dstathakis
ID: 9822488
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
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 9822545
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
 

Author Comment

by:Dstathakis
ID: 9822647
thanks you've been alot of help!
0
 

Author Comment

by:Dstathakis
ID: 9827280
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 9829283
The recordset didn't open correctly.

How is it declared?

mlmcc
0
 

Author Comment

by:Dstathakis
ID: 9829512
Sorry, I was finally able to figure it out.

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 9829591
Glad I could help

mlmcc
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Introduction to Processes
Starting up a Project

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question