Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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 04-23-07, 07:00
elskan elskan is offline
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 04-23-07, 07:46
georgev georgev is offline
SQL Apprentice
 
Join Date: Jan 2007
Location: hiding
Posts: 8,139
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
You only stop learning when you stop asking questions.
Reply With Quote
  #3 (permalink)  
Old 04-24-07, 14:55
elskan elskan is offline
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 04-25-07, 04:28
georgev georgev is offline
SQL Apprentice
 
Join Date: Jan 2007
Location: hiding
Posts: 8,139
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
You only stop learning when you stop asking questions.
Reply With Quote
  #5 (permalink)  
Old 04-26-07, 06:19
elskan elskan is offline
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

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