Solved

Help with Code to work!  ASP , SQL

Posted on 2003-11-25
13
377 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now