Can you use ASP ADO "Like" to perform a "Not Like" search?

Discussion in 'ASP General' started by Adam Short, Apr 14, 2005.

  1. Adam Short

    Adam Short Guest

    I've never needed it before but now I do!

    Does anyone know if you are able to perform a NOT Like search using Classic
    ASP ADO?

    i.e. myData.Filter = "Ref NOT LIKE '*1234*'"

    by the way this doesn't work!! and neither does myData.Filter = "Ref <> LIKE
    '*1234*'"

    or myData.Filter = "NOT Ref LIKE '*1234*'"

    Regards

    Adam



    --
    Phuture-UK +44 (01202) 518122
    Adam Short, Apr 14, 2005
    #1
    1. Advertising

  2. What kind of database?

    Also, don't use the filter method of the recordset. By doing that, you're
    bringing back all kinds of data that you have no use for, only to filter it
    out after the fact. Instead, handle the filtering in the query itself.

    SELECT this, that, theOther FROM yourTable WHERE Ref NOT LIKE '%1234%'


    Ray at work

    "Adam Short" <> wrote in message
    news:...
    > I've never needed it before but now I do!
    >
    > Does anyone know if you are able to perform a NOT Like search using

    Classic
    > ASP ADO?
    >
    > i.e. myData.Filter = "Ref NOT LIKE '*1234*'"
    >
    > by the way this doesn't work!! and neither does myData.Filter = "Ref <>

    LIKE
    > '*1234*'"
    >
    > or myData.Filter = "NOT Ref LIKE '*1234*'"
    >
    > Regards
    >
    > Adam
    >
    >
    >
    > --
    > Phuture-UK +44 (01202) 518122
    >
    >
    Ray Costanzo [MVP], Apr 14, 2005
    #2
    1. Advertising

  3. Adam Short wrote:
    > I've never needed it before but now I do!
    >
    > Does anyone know if you are able to perform a NOT Like search using
    > Classic ASP ADO?
    >
    > i.e. myData.Filter = "Ref NOT LIKE '*1234*'"
    >
    > by the way this doesn't work!! and neither does myData.Filter = "Ref
    > <> LIKE '*1234*'"
    >
    > or myData.Filter = "NOT Ref LIKE '*1234*'"
    >
    > Regards
    >
    > Adam
    >

    No, the NOT keyword is not allowed in the Filter property. While I echo
    Ray's advice to use a WHERE clause in your sql string, I do recognized that
    you may need to do multiple filters against the same set of records,
    hopefully using a disconnected recordset. In this circumstance, here is a
    workaround:

    What you can do is use the Clone method to create a new copy of the
    recordset, apply the filter to the clone using LIKE, delete the records
    resulting from the filter from the clone and remove the filter.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Apr 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nita
    Replies:
    1
    Views:
    857
    Saravana
    Nov 20, 2004
  2. ronaldlee

    Transfer ADO Code to ADO.NET

    ronaldlee, Dec 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    446
    Kevin Spencer
    Dec 17, 2004
  3. Replies:
    2
    Views:
    2,857
    Toby Inkster
    Aug 15, 2004
  4. Moose
    Replies:
    6
    Views:
    15,300
    Alfonso Esteban Perdigón
    Aug 17, 2004
  5. Arturo
    Replies:
    0
    Views:
    172
    Arturo
    Feb 6, 2004
Loading...

Share This Page