Solved

Help with Code to work!  ASP , SQL

Posted on 2003-11-25
13
381 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
  • 7
  • 6
13 Comments
 
LVL 100

Expert Comment

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

mlmcc
0
 
LVL 100

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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 100

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 100

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 100

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 100

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 100

Expert Comment

by:mlmcc
ID: 9829591
Glad I could help

mlmcc
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

831 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