Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Using NOT LIKE in Query String????

Reply
Thread Tools

Using NOT LIKE in Query String????

 
 
David Lozzi
Guest
Posts: n/a
 
      08-08-2003
OK, I know how to use [field LIKE '%keyword%'] to pull up all records that
contains the keyword, but what about not containing the keyword? I've tried
NOT LIKE but i get

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another

Any ideas?
Thanks!

--
David Lozzi
Associated Business & Technology Group
www.associatedbtg.com

I should've known that....but I had a brain fart.


 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
SELECT [whatever] FROM [whatever] WHERE [whatever] NOT LIKE '%whatever%'

Post your SQL string and your database type and info.

Ray at work

"David Lozzi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OK, I know how to use [field LIKE '%keyword%'] to pull up all records that
> contains the keyword, but what about not containing the keyword? I've

tried
> NOT LIKE but i get
>
> Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another
>
> Any ideas?
> Thanks!
>
> --
> David Lozzi
> Associated Business & Technology Group
> www.associatedbtg.com
>
> I should've known that....but I had a brain fart.
>
>



 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
Yes, I see. I also get the same error when trying NOT like. Why are you
doing this like this?

Ray at work



"David Lozzi" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I see. I am using the filter option of the recordset. I am just loading

the
> recordset with my own information, this is not being pulled from a
> database... like this:
>
> set rec = server.CreateObject("ADODB.Recordset")
> rec.CursorLocation = 3
> rec.Fields.Append "user", adVarChar, 255
> rec.Fields.Append "supervisor", adVarChar, 255
> ........
> rec.Fields.Append "HazardDate", adDate
> rec.Fields.Append "OSHA", adVarChar, 10
> rec.Open
> rec.filter = filt
>
> if NOT LIKE is used for SQL queries, is there an option for this scenario?
>
> thanks,
>
> --
> David Lozzi
> Associated Business & Technology Group
> www.associatedbtg.com
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
I cannot find any definitive statement indicating that NOT like is not
supported in the filter method of an RS, but I do see others having the
problems without any solutions, out there on the WWW. Hmm. Perhaps someone
else has read this thread this far and can enlighten us.

Ray at work

"David Lozzi" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I see. I am using the filter option of the recordset. I am just loading

the
> recordset with my own information, this is not being pulled from a
> database... like this:
>
> set rec = server.CreateObject("ADODB.Recordset")
> rec.CursorLocation = 3
> rec.Fields.Append "user", adVarChar, 255
> rec.Fields.Append "supervisor", adVarChar, 255
> ........
> rec.Fields.Append "HazardDate", adDate
> rec.Fields.Append "OSHA", adVarChar, 10
> rec.Open
> rec.filter = filt
>
> if NOT LIKE is used for SQL queries, is there an option for this scenario?
>
> thanks,
>
> --



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      08-08-2003

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eQJT$(E-Mail Removed)...
> I cannot find any definitive statement indicating that NOT like is not
> supported in the filter method of an RS, but I do see others having the
> problems without any solutions, out there on the WWW. Hmm. Perhaps

someone
> else has read this thread this far and can enlighten us.


Can you use not as a logical operator in those statements? For simplicity,
something like NOT TRUE?

If so, then it sounds like a syntax issue. Are precedence operators
allowed? You could try to evaluate LIKE '%xxx%' and then negate it with a
NOT.

NOT (LIKE '%xxx%')

I don't know why it would be so picky about syntax, but it's worth a try.

--
Mike


 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
I mean property. Eegs.

Ray at work

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%(E-Mail Removed)...
> Aaron, would you happen to know if "not like" is officially unsupported in
> the filter method?
>
> And I 100% agree, but OP did not answer why he chose this method.
>
> Ray at work
>
> "Aaron Bertrand - MVP" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > > I see. I am using the filter option of the recordset.

> >
> > Why? Build a SQL string with a WHERE clause. Much more efficient and

> less
> > problematic... if you're only interested in the records that are not

like
> > '%whatever%', why bother bringing back ALL rows and then filtering them?
> >
> >

>
>



 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      08-08-2003
> Aaron, would you happen to know if "not like" is officially unsupported in
> the filter method?


I think Tom's link implies that it is not supported.

If the search string is only one character, you can mimic a NOT LIKE using
LIKE, at least against SQL Server, this way (try it in Query Analyzer):



DECLARE @strPattern VARCHAR(32)
SET @strPattern = 'o'

CREATE TABLE [dbo].[fakeUsers]
(
[name] [VARCHAR] (32)
)

INSERT fakeUsers VaLUES('frank')
INSERT fakeUsers VaLUES('bob')
INSERT fakeUsers VaLUES('moo')

SELECT * FROM fakeUsers WHERE name NOT LIKE '%'+@strPattern+'%'
SELECT * FROM fakeUsers WHERE name LIKE REPLICATE('[^'+@strPattern+']',
DATALENGTH(name))

DROP TABLE fakeUsers


However I'm not confident that ADO will interpret this the same way. And it
won't work quite as easily if the search sequence is larger than one
character...

A


 
Reply With Quote
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      08-08-2003
> I mean property. Eegs.

Oh, you're going to hell now, because when you said "method" nobody knew
what you were talking about.


 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
Considering I think I said it multiple times, I think you're right. I'm
already working on www.hell.666 site for Lucifer.

Ray at work

"Aaron Bertrand - MVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > I mean property. Eegs.

>
> Oh, you're going to hell now, because when you said "method" nobody knew
> what you were talking about.
>
>



 
Reply With Quote
 
Matt Smith
Guest
Posts: n/a
 
      08-11-2003
"David Lozzi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OK, I know how to use [field LIKE '%keyword%'] to pull up all records that
> contains the keyword, but what about not containing the keyword? I've

tried
> NOT LIKE but i get
>
> Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another


Since I've never used the filter property this is a long shot but my
literature on the recordset object suggests that you should use relational
operators (<, <=,>,>=,= and <>) for this sort of operation.
Have you tried this already?

Matt


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP LIKE query using parameterized query Roland Hall ASP General 8 01-13-2007 05:08 AM
LIKE not working for Access Query in ASP.NET 2.0 Anthony Bollinger ASP .Net 2 10-30-2006 01:39 PM
object-like macro used like function-like macro Patrick Kowalzick C++ 5 03-14-2006 03:30 PM
Trying to query the Address table data of AdventureWorks database from Query Analyzer - need help! Learner ASP .Net 1 01-30-2006 08:58 PM
Can you use ASP ADO "Like" to perform a "Not Like" search? Adam Short ASP General 2 04-14-2005 01:20 PM



Advertisments