473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using NOT LIKE in Query String????

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.
Jul 19 '05 #1
14 10425
SELECT [whatever] FROM [whatever] WHERE [whatever] NOT LIKE '%whatever%'

Post your SQL string and your database type and info.

Ray at work

"David Lozzi" <dl****@associatedbtg.com> wrote in message
news:OR*************@TK2MSFTNGP10.phx.gbl...
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.

Jul 19 '05 #2
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" <dl****@associatedbtg.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Jul 19 '05 #3
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" <dl****@associatedbtg.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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,

--

Jul 19 '05 #4

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eQ**************@tk2msftngp13.phx.gbl...
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
Jul 19 '05 #5
I mean property. Eegs.

Ray at work

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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" <aa***@TRASHaspfaq.com> wrote in message
news:e9**************@tk2msftngp13.phx.gbl...
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?


Jul 19 '05 #6
> 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
Jul 19 '05 #7
> I mean property. Eegs.

Oh, you're going to hell now, because when you said "method" nobody knew
what you were talking about.
Jul 19 '05 #8
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" <aa***@TRASHaspfaq.com> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...
I mean property. Eegs.


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

Jul 19 '05 #9
"David Lozzi" <dl****@associatedbtg.com> wrote in message
news:OR*************@TK2MSFTNGP10.phx.gbl...
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
Jul 19 '05 #10
What I am doing is reading through a recordset pulled from a SQL statement
query. I am loading some of these fields along with other fields based on
mathematical assumptions on the previous fields. For example:

sql = Select statement
rec = recordset

do until sql.eof
cnt = cnt + 1
rec("a") = sql("a")
rec("b") = sql("b")
rec("c") = sql("d") - (sql("e") / 4")
rec("d") = cnt
sql.movenext
loop

now i want to be able to filter the rec recordset. THe user has the option
to search NOT keyword. Can I repost a SQL Select statement against the rec
recordset?

thanks!

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

I should've known that....but I had a brain fart.
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Can you provide an actual full SQL statement that gives you the error?
The problem is that the error is not coming from a SQL statement that

David is generating. The error is coming from attempting to apply a NOT LIKE
criteria to the filter property of an ADODB.Recordset. In other words, he's already sent a SQL statement to the database, and now in the ASP code he
wants to limit the records he's already retrieved by applying a filter.
Which, IMHO, belongs in the WHERE clause of the original statement.

Jul 19 '05 #11
I think you should consider showing a little more code.
When you say you are reading through a recordset pulled from a SQL statement
query....Does this mean you really are using a database? then you are
creating the ad hoc recordset?

Could you not use your "filter" logic before adding the item to the
recordset?
Would an array work better?


"David Lozzi" <dl****@associatedbtg.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
What I am doing is reading through a recordset pulled from a SQL statement
query. I am loading some of these fields along with other fields based on
mathematical assumptions on the previous fields. For example:

sql = Select statement
rec = recordset

do until sql.eof
cnt = cnt + 1
rec("a") = sql("a")
rec("b") = sql("b")
rec("c") = sql("d") - (sql("e") / 4")
rec("d") = cnt
sql.movenext
loop

now i want to be able to filter the rec recordset. THe user has the option
to search NOT keyword. Can I repost a SQL Select statement against the rec
recordset?

thanks!

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

I should've known that....but I had a brain fart.
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Can you provide an actual full SQL statement that gives you the error?


The problem is that the error is not coming from a SQL statement that

David
is generating. The error is coming from attempting to apply a NOT LIKE
criteria to the filter property of an ADODB.Recordset. In other words,

he's
already sent a SQL statement to the database, and now in the ASP code he
wants to limit the records he's already retrieved by applying a filter.
Which, IMHO, belongs in the WHERE clause of the original statement.


Jul 19 '05 #12
My initial instinct is to agree with Tom. I haven't seen any reason yet for
the ad hoc recordset. That's not to say you don't have one: just that you
haven't sufficiently explained why you need one. So far, there isn't
anything you are doing that could not be done more efficiently with an
array. Even if you do need the ad hoc recordset, the "NOT" functionality
should be pushed back further into the SQL statement where it belongs (as
suggested by Aaron and others). You're pulling too much data across the
wire.

Bob Barrows

David Lozzi wrote:
What I am doing is reading through a recordset pulled from a SQL
statement query. I am loading some of these fields along with other
fields based on mathematical assumptions on the previous fields. For
example:

sql = Select statement
rec = recordset

do until sql.eof
cnt = cnt + 1
rec("a") = sql("a")
rec("b") = sql("b")
rec("c") = sql("d") - (sql("e") / 4")
rec("d") = cnt
sql.movenext
loop

now i want to be able to filter the rec recordset. THe user has the
option to search NOT keyword. Can I repost a SQL Select statement
against the rec recordset?

thanks!
I should've known that....but I had a brain fart.
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Can you provide an actual full SQL statement that gives you the
error?


The problem is that the error is not coming from a SQL statement
that David is generating. The error is coming from attempting to
apply a NOT LIKE criteria to the filter property of an
ADODB.Recordset. In other words, he's already sent a SQL statement
to the database, and now in the ASP code he wants to limit the
records he's already retrieved by applying a filter. Which, IMHO,
belongs in the WHERE clause of the original statement.

Jul 19 '05 #13
Bob Barrows wrote:
No. He (David, the OP) has not sent a SQL statement to a database.


I take that back.
Bob
Jul 19 '05 #14
OK, I will work with that.

Thank you all for your support.

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

I should've known that....but I had a brain fart.
"Bob Barrows" <re*******@yahoo.com> wrote in message
news:#s**************@TK2MSFTNGP12.phx.gbl...
My initial instinct is to agree with Tom. I haven't seen any reason yet for the ad hoc recordset. That's not to say you don't have one: just that you
haven't sufficiently explained why you need one. So far, there isn't
anything you are doing that could not be done more efficiently with an
array. Even if you do need the ad hoc recordset, the "NOT" functionality
should be pushed back further into the SQL statement where it belongs (as
suggested by Aaron and others). You're pulling too much data across the
wire.

Bob Barrows

David Lozzi wrote:
What I am doing is reading through a recordset pulled from a SQL
statement query. I am loading some of these fields along with other
fields based on mathematical assumptions on the previous fields. For
example:

sql = Select statement
rec = recordset

do until sql.eof
cnt = cnt + 1
rec("a") = sql("a")
rec("b") = sql("b")
rec("c") = sql("d") - (sql("e") / 4")
rec("d") = cnt
sql.movenext
loop

now i want to be able to filter the rec recordset. THe user has the
option to search NOT keyword. Can I repost a SQL Select statement
against the rec recordset?

thanks!
I should've known that....but I had a brain fart.
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
Can you provide an actual full SQL statement that gives you the
error?

The problem is that the error is not coming from a SQL statement
that David is generating. The error is coming from attempting to
apply a NOT LIKE criteria to the filter property of an
ADODB.Recordset. In other words, he's already sent a SQL statement
to the database, and now in the ASP code he wants to limit the
records he's already retrieved by applying a filter. Which, IMHO,
belongs in the WHERE clause of the original statement.


Jul 19 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Phil Powell | last post by:
I created a page that will be doing image resizing and manipulation, which seems to work (using GD library). However, upon returning to the page where the image has been changed, I still see the...
3
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters...
2
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game...
3
by: Dr. Oz | last post by:
Hi, I am trying to read in a query string from one page and build a link to another page based on the query string. Here's the code I am using to read in the query string: <script...
1
by: anshul | last post by:
Can somebody tell me about state management in asp.net using Query Strings. I am just unable to understand this. Anshul
18
by: A.M | last post by:
Hi, Is there any way to call a WSS web service method by using browser and see the XML result in browser as well? I have been told that there is query string syntax for calling...
2
by: Milkstr | last post by:
is it possible to pass dynamic text through the query string command?? I know you can just pass a variale through a link eg. www.text1.com/text1.asp?username="Mike" but i want to use the...
3
by: Skip | last post by:
OK, I'm a novice in JS but have lots of coding experience. I am trying to accomplish something that would seem somewhat simple - BUT IT'S NOT. I have a basic window that calls another window...
1
by: agarwasa2008 | last post by:
Hi, I am new to VB .NET programming. I need to display a value on a web form called FeatureList.aspx. Here are the details: The web form FeatureSearch.aspx contains a user control called...
4
by: madhumy | last post by:
I am having Arraylist containg list of data, Now I am using a Session variable concept to Pass the Arraylist to next page, Instead I want to use Querystring method, can it be done? I need code help.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.