Results 1 to 5 of 5
  1. #1
    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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,065
    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

  3. #3
    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

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,065
    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

  5. #5
    Join Date
    Apr 2005
    Posts
    30
    Thanks very much George. Nice one

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •