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

A

Adam Short

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
 
R

Ray Costanzo [MVP]

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
 
B

Bob Barrows [MVP]

Adam said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top