Solved

Help with Code to work!  ASP , SQL

Posted on 2003-11-25
13
379 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 102
python sqlite question 11 46
MacOS and programming in React 7 35
Regular Expression Calculator Tester 2 73
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A short article about a problem I had getting the GPS LocationListener working.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

772 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