If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Using 'OR' in If statements

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Apr 2005
Posts: 30
Using 'OR' in If statements

Hi Everyone,

I am trying to figure out how to correctly write a conditional statement in Classic ASP that requires an OR in it.

I want something like

If x <> "1" OR "2" Then
do something
Else
do something else
End If

Is this possible? Am I being a complete dimwit? does ASP recognise the OR word.

I have had a look on google and yahoo but I haven't found anything that explains in detail.

Thanks in advance

Jamie
Reply With Quote
  #2 (permalink)  
Old
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 11,057
Try this:
Code:
If x <> "1" OR x <> "2" Then
do something
Else
do something else
End If
Computers are not as clever as you, you have the be very specific!
Note that this is the same for the AND condition
__________________
George
Home | Blog
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Apr 2005
Posts: 30
Thanks for your help George.

I am having the same with an SQL Statement now.

I'm not sure if I should post here so please accept my apologies if it is in the wrong forum

I am getting an error on this SQL statement

"SELECT product_id FROM products WHERE product_name LIKE '%"&srch&"%' AND description LIKE '%"&srch&"%' ;"

Is my syntax wrong (again! )


Thanks in advance
Reply With Quote
  #4 (permalink)  
Old
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 11,057
Ok, you're confusing your single and double quotes!
It's easily done, so not to worry. Remember that you want to wrap your percent signs with singles and anything that's not a variable needs wrapping in double quotes.
Code:
"SELECT product_id FROM products WHERE product_name LIKE '%'" & srch& "'%' AND description LIKE '%'" & srch & "'%' ;"
For every opening quote, there's a closing
__________________
George
Home | Blog
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Apr 2005
Posts: 30
Thanks very much George. Nice one
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On