Connecting Tech Pros Worldwide Forums | Help | Site Map

Syntax error (missing operator) in query expression

shank
Guest
 
Posts: n/a
#1: Jul 19 '05
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.

2) I searched ASPFAQ and came up blank. Where can find the "rules" for when
and how to use single quotes and double quotes in ASP?

thanks!
----------------------
SQL = SQL & "WHERE '" &
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.
Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","") &
"' LIKE '%' '" & T & "' '%' "



Bob Lehmann
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Syntax error (missing operator) in query expression


What the heck is this....
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE
all about?

Bob Lehmann

"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
when[color=blue]
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")[/color]
&[color=blue]
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Bob Lehmann
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Syntax error (missing operator) in query expression


What the heck is this....
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE
all about?

Bob Lehmann

"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
when[color=blue]
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")[/color]
&[color=blue]
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Anthony
Guest
 
Posts: n/a
#4: Jul 19 '05

re: Syntax error (missing operator) in query expression


What on earth are you trying to do? I can't imagine the text your trying to
replace... post the sample text.. I'd imagine there is a much better way to
do it...

I can't wrap my head around that no matter how hard I try...

sorry...
"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
when[color=blue]
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")[/color]
&[color=blue]
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Anthony
Guest
 
Posts: n/a
#5: Jul 19 '05

re: Syntax error (missing operator) in query expression


What on earth are you trying to do? I can't imagine the text your trying to
replace... post the sample text.. I'd imagine there is a much better way to
do it...

I can't wrap my head around that no matter how hard I try...

sorry...
"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
when[color=blue]
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")[/color]
&[color=blue]
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Aaron [SQL Server MVP]
Guest
 
Posts: n/a
#6: Jul 19 '05

re: Syntax error (missing operator) in query expression


Shank, you need to start with something simple and work from there. They
don't let the rookie at NASA go up in the space shuttle by himself.

--
http://www.aspfaq.com/
(Reverse address to reply.)





"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for
> when
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
> REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")
> &
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Aaron [SQL Server MVP]
Guest
 
Posts: n/a
#7: Jul 19 '05

re: Syntax error (missing operator) in query expression


Shank, you need to start with something simple and work from there. They
don't let the rookie at NASA go up in the space shuttle by himself.

--
http://www.aspfaq.com/
(Reverse address to reply.)





"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for
> when
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
> REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")
> &
> "' LIKE '%' '" & T & "' '%' "
>
>[/color]


Bob Barrows [MVP]
Guest
 
Posts: n/a
#8: Jul 19 '05

re: Syntax error (missing operator) in query expression


shank wrote:[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules"
> for when and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".",""),"
> ",""),"the",""),"and",""),"&",""),"/","") & "' LIKE '%' '" & T & "'
> '%' "[/color]

shank, we (you) can't possibly begin to debug a syntax error in a query
expression without knowing what the actual query expression is. Showing us
the vbscript code that generates the query expression does not help. You
need to response.write the expression so we (you) can see that actual
resulting statement that is generating the syntax error:

Response.Write SQL
Response.End

In addition, we cannot help unless you tell us the type and version of
database you are using.

Bob Barrows
PS, I reiterate: queries should be designed and tested in the database's
query execution tool BEFORE you attempt to run them via ASP.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Chris Hohmann
Guest
 
Posts: n/a
#9: Jul 19 '05

re: Syntax error (missing operator) in query expression


"shank" <shank@tampabay.rr.com> wrote in message
news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1) I'm getting this error: Syntax error (missing operator) in query
> expression on the below statement. Can I get some advice.
>
> 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
when[color=blue]
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue]
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")[/color]
&[color=blue]
> "' LIKE '%' '" & T & "' '%' "
>[/color]

This appears to be related to your other "syntax error" post. If so, it may
have been better to post a follow-up to that thread. Given that context, it
appears that you're attempting to eliminate false positives from your
searches by discluding common words and punctuations. If this is the case,
perhaps it would be easier to remove those items from the search term
instead of attempting to remove them from the GenKTitles.Title column in
your database. If you took this approach you could make use of a regular
expression to "scrub" the search term prior to constructing the SQL
statement. Also, please consider using a stored procedure (or parameterized
query depending on your database environment) instead of dynamically
constructing the SQL statement. Also, in the future, please provide
database, version, DDL, sample data and desired output/results. Here's are
some guidelines

http://aspfaq.com/5000


Aaron [SQL Server MVP]
Guest
 
Posts: n/a
#10: Jul 19 '05

re: Syntax error (missing operator) in query expression


> http://aspfaq.com/5000

http://www.aspfaq.com/5006


Chris Hohmann
Guest
 
Posts: n/a
#11: Jul 19 '05

re: Syntax error (missing operator) in query expression


"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:O99PsDNfEHA.3476@tk2msftngp13.phx.gbl...[color=blue][color=green]
> > http://aspfaq.com/5000[/color]
>
> http://www.aspfaq.com/5006
>[/color]

Yeah, that's what I put first, but I think 5003, 5006 and 5009 were all in
play. 5003 is a little bit of a stretch. This was more of a "stick to one
thread situation" or "please provide historical context" situation and not
so much a "please don't multi-post" one.


shank
Guest
 
Posts: n/a
#12: Jul 19 '05

re: Syntax error (missing operator) in query expression


It was and it wasn't related to the other post. There were 2 issues and if I
could have gotten through either, I probably could have gotten through both.
The reason I don't post everything is it looks like a huge mess of code
coming through the newsgroup. And I just figured it would make things more
confusing. Here is the entire recordset created in dreamweaver. It works
fine as it is here. I know you code heads may not like dreamweaver but it's
a huge crutch for those of us that don't have the knowledge to hand code
things. It works very well for what I want to do, up until I want to give an
extra effort to make things better. For this project I have to use Access
2002. I don't like it, but that's not my choice. I have a music database
that users can search. I get titles and artists from many many sources. They
all choose to spell titles and artists their own way. That's a problem. In
an effort to make it easier on the end users, I want to remove common words
and punctuation that varies. That includes "'", """, ",", "/", " ", "&",
"the", and "and". If I remove those characters from both terms, it creates a
much better chance of relevant search results. I've done this with SQL
stored procedures and it works great. Now I have to do this with SQL in ASP
and I'm having a lot of syntax problems. I appreciate everyone's help!!! I
thought I was trying to make it easier on everyone and I guess I made it
more confusing. Sorry!

I only have to remove those characters from titles and artists fields. The
other fields I have control over the data. OK... now how do I accomplish
this feat?
thanks!

<%
Dim rsResults__T
rsResults__T = "%"
If (Request("title") <> "") Then
rsResults__T = Request("title")
End If
%>
<%
Dim rsResults__A
rsResults__A = "%"
If (Request("artist") <> "") Then
rsResults__A = Request("artist")
End If
%>
<%
Dim rsResults__C
rsResults__C = "%"
If (Request("category") <> "") Then
rsResults__C = Request("category")
End If
%>
<%
Dim rsResults__TY
rsResults__TY = "%"
If (Request("type") <> "") Then
rsResults__TY = Request("type")
End If
%>
<%
Dim rsResults__M
rsResults__M = "%"
If (Request("manuf") <> "") Then
rsResults__M = Request("manuf")
End If
%>
<%
Dim rsResults__SA
rsResults__SA = "%"
If (Request("singleartist") <> "") Then
rsResults__SA = Request("singleartist")
End If
%>
<%
Dim rsResults
Dim rsResults_numRows

Set rsResults = Server.CreateObject("ADODB.Recordset")
rsResults.ActiveConnection = MM_GenKAccess_STRING
rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE
(GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") + "' +
'%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A, "'",
"''") + "' + '%') AND (GenKStock.Category LIKE '" +
Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE '" +
Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist LIKE
'" + Replace(rsResults__SA, "'", "''") + "')"
rsResults.CursorType = 0
rsResults.CursorLocation = 2
rsResults.LockType = 1
rsResults.Open()

rsResults_numRows = 0
%>

"Chris Hohmann" <nospam@thankyou.com> wrote in message
news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...[color=blue]
> "shank" <shank@tampabay.rr.com> wrote in message
> news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=green]
> > 1) I'm getting this error: Syntax error (missing operator) in query
> > expression on the below statement. Can I get some advice.
> >
> > 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
> when[color=green]
> > and how to use single quotes and double quotes in ASP?
> >
> > thanks!
> > ----------------------
> > SQL = SQL & "WHERE '" &
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green]
> > Title","'",""),",",""),".",""),"[/color][/color]
",""),"the",""),"and",""),"&",""),"/","")[color=blue]
> &[color=green]
> > "' LIKE '%' '" & T & "' '%' "
> >[/color]
>
> This appears to be related to your other "syntax error" post. If so, it[/color]
may[color=blue]
> have been better to post a follow-up to that thread. Given that context,[/color]
it[color=blue]
> appears that you're attempting to eliminate false positives from your
> searches by discluding common words and punctuations. If this is the case,
> perhaps it would be easier to remove those items from the search term
> instead of attempting to remove them from the GenKTitles.Title column in
> your database. If you took this approach you could make use of a regular
> expression to "scrub" the search term prior to constructing the SQL
> statement. Also, please consider using a stored procedure (or[/color]
parameterized[color=blue]
> query depending on your database environment) instead of dynamically
> constructing the SQL statement. Also, in the future, please provide
> database, version, DDL, sample data and desired output/results. Here's are
> some guidelines
>
> http://aspfaq.com/5000
>
>[/color]


Bob Lehmann
Guest
 
Posts: n/a
#13: Jul 19 '05

re: Syntax error (missing operator) in query expression


>>>It works very well for what I want to do, up until I want to give an
extra effort to make things better.
So what you're saying is, it doesn't work very well for what you *really*
want to do? Maybe it's time to move on?

That's the problem with automagical code generation tools - they try to
account for every possible circumstance, write overly-verbose code that
noone can follow, and make it even worse by appending a proprietary prefix
to the variables. Look at me, MM_MacroMedia made this! And in the end, they
don't do that one thing that the developer had in mind.

What's even worse, is that newbies attempt to do things they don't
understand, and end up trying to fix the thing don't understand by wading
through the incomprehensible code generated by the <not>helpful</not> tool.

From the code you provided, you are doing lots of LIKEs without a wildcard
when a value is entered. So you would end up with something like this...
AND (GenKStock.SingleArtist LIKE 'jo') in your query if someone typed 'jo'
in your search form.

Suggestions -
You should specify the collection in the Request object you are using.
Request.Form("field_name"), Request.QueryString("field_name"), etc....
Your test for "" is unreliable. You should check the length of the
string or...

If Not Request.Form ("title") = "" Then
.....
End If

For concatenation, "&" is the correct operator in VB - "+" can cause
some unexpected esults if the value is number.
Consider doing the Replace in your If staements to make the SQL more
readable in the code.
Also, write a function to do the replacing so you don't have to keep
writing - Replace(rsResults__TY, "'", "''") - over and over.

Bob Barrows's advice to response.write the query to make sure it works in
Access, and Aaron's advice to start simple, are probably the best two pieces
of advice should follow.

Bob Lehmann

"shank" <shank@tampabay.rr.com> wrote in message
news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...[color=blue]
> It was and it wasn't related to the other post. There were 2 issues and if[/color]
I[color=blue]
> could have gotten through either, I probably could have gotten through[/color]
both.[color=blue]
> The reason I don't post everything is it looks like a huge mess of code
> coming through the newsgroup. And I just figured it would make things more
> confusing. Here is the entire recordset created in dreamweaver. It works
> fine as it is here. I know you code heads may not like dreamweaver but[/color]
it's[color=blue]
> a huge crutch for those of us that don't have the knowledge to hand code
> things. It works very well for what I want to do, up until I want to give[/color]
an[color=blue]
> extra effort to make things better. For this project I have to use Access
> 2002. I don't like it, but that's not my choice. I have a music database
> that users can search. I get titles and artists from many many sources.[/color]
They[color=blue]
> all choose to spell titles and artists their own way. That's a problem. In
> an effort to make it easier on the end users, I want to remove common[/color]
words[color=blue]
> and punctuation that varies. That includes "'", """, ",", "/", " ", "&",
> "the", and "and". If I remove those characters from both terms, it creates[/color]
a[color=blue]
> much better chance of relevant search results. I've done this with SQL
> stored procedures and it works great. Now I have to do this with SQL in[/color]
ASP[color=blue]
> and I'm having a lot of syntax problems. I appreciate everyone's help!!! I
> thought I was trying to make it easier on everyone and I guess I made it
> more confusing. Sorry!
>
> I only have to remove those characters from titles and artists fields. The
> other fields I have control over the data. OK... now how do I accomplish
> this feat?
> thanks!
>
> <%
> Dim rsResults__T
> rsResults__T = "%"
> If (Request("title") <> "") Then
> rsResults__T = Request("title")
> End If
> %>
> <%
> Dim rsResults__A
> rsResults__A = "%"
> If (Request("artist") <> "") Then
> rsResults__A = Request("artist")
> End If
> %>
> <%
> Dim rsResults__C
> rsResults__C = "%"
> If (Request("category") <> "") Then
> rsResults__C = Request("category")
> End If
> %>
> <%
> Dim rsResults__TY
> rsResults__TY = "%"
> If (Request("type") <> "") Then
> rsResults__TY = Request("type")
> End If
> %>
> <%
> Dim rsResults__M
> rsResults__M = "%"
> If (Request("manuf") <> "") Then
> rsResults__M = Request("manuf")
> End If
> %>
> <%
> Dim rsResults__SA
> rsResults__SA = "%"
> If (Request("singleartist") <> "") Then
> rsResults__SA = Request("singleartist")
> End If
> %>
> <%
> Dim rsResults
> Dim rsResults_numRows
>
> Set rsResults = Server.CreateObject("ADODB.Recordset")
> rsResults.ActiveConnection = MM_GenKAccess_STRING
> rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
> GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
> INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE
> (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") + "' +
> '%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A, "'",
> "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE '" +
> Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
> Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist LIKE
> '" + Replace(rsResults__SA, "'", "''") + "')"
> rsResults.CursorType = 0
> rsResults.CursorLocation = 2
> rsResults.LockType = 1
> rsResults.Open()
>
> rsResults_numRows = 0
> %>
>
> "Chris Hohmann" <nospam@thankyou.com> wrote in message
> news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...[color=green]
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > 1) I'm getting this error: Syntax error (missing operator) in query
> > > expression on the below statement. Can I get some advice.
> > >
> > > 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
> > when[color=darkred]
> > > and how to use single quotes and double quotes in ASP?
> > >
> > > thanks!
> > > ----------------------
> > > SQL = SQL & "WHERE '" &
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > Title","'",""),",",""),".",""),"[/color][/color]
> ",""),"the",""),"and",""),"&",""),"/","")[color=green]
> > &[color=darkred]
> > > "' LIKE '%' '" & T & "' '%' "
> > >[/color]
> >
> > This appears to be related to your other "syntax error" post. If so, it[/color]
> may[color=green]
> > have been better to post a follow-up to that thread. Given that context,[/color]
> it[color=green]
> > appears that you're attempting to eliminate false positives from your
> > searches by discluding common words and punctuations. If this is the[/color][/color]
case,[color=blue][color=green]
> > perhaps it would be easier to remove those items from the search term
> > instead of attempting to remove them from the GenKTitles.Title column in
> > your database. If you took this approach you could make use of a regular
> > expression to "scrub" the search term prior to constructing the SQL
> > statement. Also, please consider using a stored procedure (or[/color]
> parameterized[color=green]
> > query depending on your database environment) instead of dynamically
> > constructing the SQL statement. Also, in the future, please provide
> > database, version, DDL, sample data and desired output/results. Here's[/color][/color]
are[color=blue][color=green]
> > some guidelines
> >
> > http://aspfaq.com/5000
> >
> >[/color]
>
>[/color]


Steven Burn
Guest
 
Posts: n/a
#14: Jul 19 '05

re: Syntax error (missing operator) in query expression


I'm certainly no expert but IMHO.......

Suggestion #1. Use a regular expression to do the replacing for you

This makes for much cleaner, and easier to read code. If you'd rather not
use a RegExp for whatever reason, stick to a max of 2 "Replace's" per
line....

Suggestion #2. Use a function that contains suggestion #1

By using a function to do the replacing, it allows you to simply use;

Response.Write ReplaceThis(TheString)

.... instead of ...

Response.Write Replace(Replace(Replace.... etc etc etc

Hint:

Function ReplaceThis(sWhat)
'// RegExp or whatever, code goes here.....
End Function

Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to write the
code for you....

As has been mentioned by Bob, they screw up virtually everything.... tis
much easier (and quicker) to learn how to hand code it yourself (hint:
aspfaq.com ;o)) using Notepad or some other text editor (just make sure you
stay away from editors such as MS Word etc, if going this route as they're a
royal pain in the backside....).

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"shank" <shank@tampabay.rr.com> wrote in message
news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...[color=blue]
> It was and it wasn't related to the other post. There were 2 issues and if[/color]
I[color=blue]
> could have gotten through either, I probably could have gotten through[/color]
both.[color=blue]
> The reason I don't post everything is it looks like a huge mess of code
> coming through the newsgroup. And I just figured it would make things more
> confusing. Here is the entire recordset created in dreamweaver. It works
> fine as it is here. I know you code heads may not like dreamweaver but[/color]
it's[color=blue]
> a huge crutch for those of us that don't have the knowledge to hand code
> things. It works very well for what I want to do, up until I want to give[/color]
an[color=blue]
> extra effort to make things better. For this project I have to use Access
> 2002. I don't like it, but that's not my choice. I have a music database
> that users can search. I get titles and artists from many many sources.[/color]
They[color=blue]
> all choose to spell titles and artists their own way. That's a problem. In
> an effort to make it easier on the end users, I want to remove common[/color]
words[color=blue]
> and punctuation that varies. That includes "'", """, ",", "/", " ", "&",
> "the", and "and". If I remove those characters from both terms, it creates[/color]
a[color=blue]
> much better chance of relevant search results. I've done this with SQL
> stored procedures and it works great. Now I have to do this with SQL in[/color]
ASP[color=blue]
> and I'm having a lot of syntax problems. I appreciate everyone's help!!! I
> thought I was trying to make it easier on everyone and I guess I made it
> more confusing. Sorry!
>
> I only have to remove those characters from titles and artists fields. The
> other fields I have control over the data. OK... now how do I accomplish
> this feat?
> thanks!
>
> <%
> Dim rsResults__T
> rsResults__T = "%"
> If (Request("title") <> "") Then
> rsResults__T = Request("title")
> End If
> %>
> <%
> Dim rsResults__A
> rsResults__A = "%"
> If (Request("artist") <> "") Then
> rsResults__A = Request("artist")
> End If
> %>
> <%
> Dim rsResults__C
> rsResults__C = "%"
> If (Request("category") <> "") Then
> rsResults__C = Request("category")
> End If
> %>
> <%
> Dim rsResults__TY
> rsResults__TY = "%"
> If (Request("type") <> "") Then
> rsResults__TY = Request("type")
> End If
> %>
> <%
> Dim rsResults__M
> rsResults__M = "%"
> If (Request("manuf") <> "") Then
> rsResults__M = Request("manuf")
> End If
> %>
> <%
> Dim rsResults__SA
> rsResults__SA = "%"
> If (Request("singleartist") <> "") Then
> rsResults__SA = Request("singleartist")
> End If
> %>
> <%
> Dim rsResults
> Dim rsResults_numRows
>
> Set rsResults = Server.CreateObject("ADODB.Recordset")
> rsResults.ActiveConnection = MM_GenKAccess_STRING
> rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
> GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
> INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE
> (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") + "' +
> '%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A, "'",
> "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE '" +
> Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
> Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist LIKE
> '" + Replace(rsResults__SA, "'", "''") + "')"
> rsResults.CursorType = 0
> rsResults.CursorLocation = 2
> rsResults.LockType = 1
> rsResults.Open()
>
> rsResults_numRows = 0
> %>
>
> "Chris Hohmann" <nospam@thankyou.com> wrote in message
> news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...[color=green]
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > 1) I'm getting this error: Syntax error (missing operator) in query
> > > expression on the below statement. Can I get some advice.
> > >
> > > 2) I searched ASPFAQ and came up blank. Where can find the "rules" for[/color]
> > when[color=darkred]
> > > and how to use single quotes and double quotes in ASP?
> > >
> > > thanks!
> > > ----------------------
> > > SQL = SQL & "WHERE '" &
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > Title","'",""),",",""),".",""),"[/color][/color]
> ",""),"the",""),"and",""),"&",""),"/","")[color=green]
> > &[color=darkred]
> > > "' LIKE '%' '" & T & "' '%' "
> > >[/color]
> >
> > This appears to be related to your other "syntax error" post. If so, it[/color]
> may[color=green]
> > have been better to post a follow-up to that thread. Given that context,[/color]
> it[color=green]
> > appears that you're attempting to eliminate false positives from your
> > searches by discluding common words and punctuations. If this is the[/color][/color]
case,[color=blue][color=green]
> > perhaps it would be easier to remove those items from the search term
> > instead of attempting to remove them from the GenKTitles.Title column in
> > your database. If you took this approach you could make use of a regular
> > expression to "scrub" the search term prior to constructing the SQL
> > statement. Also, please consider using a stored procedure (or[/color]
> parameterized[color=green]
> > query depending on your database environment) instead of dynamically
> > constructing the SQL statement. Also, in the future, please provide
> > database, version, DDL, sample data and desired output/results. Here's[/color][/color]
are[color=blue][color=green]
> > some guidelines
> >
> > http://aspfaq.com/5000
> >
> >[/color]
>
>[/color]


shank
Guest
 
Posts: n/a
#15: Jul 19 '05

re: Syntax error (missing operator) in query expression


Thanks to all, but if I can't get past a few syntax issues, I'll never get
past creating a function.

"Steven Burn" <pvt@noyb.com> wrote in message
news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...[color=blue]
> I'm certainly no expert but IMHO.......
>
> Suggestion #1. Use a regular expression to do the replacing for you
>
> This makes for much cleaner, and easier to read code. If you'd rather not
> use a RegExp for whatever reason, stick to a max of 2 "Replace's" per
> line....
>
> Suggestion #2. Use a function that contains suggestion #1
>
> By using a function to do the replacing, it allows you to simply use;
>
> Response.Write ReplaceThis(TheString)
>
> ... instead of ...
>
> Response.Write Replace(Replace(Replace.... etc etc etc
>
> Hint:
>
> Function ReplaceThis(sWhat)
> '// RegExp or whatever, code goes here.....
> End Function
>
> Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to write[/color]
the[color=blue]
> code for you....
>
> As has been mentioned by Bob, they screw up virtually everything.... tis
> much easier (and quicker) to learn how to hand code it yourself (hint:
> aspfaq.com ;o)) using Notepad or some other text editor (just make sure[/color]
you[color=blue]
> stay away from editors such as MS Word etc, if going this route as they're[/color]
a[color=blue]
> royal pain in the backside....).
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
>
> "shank" <shank@tampabay.rr.com> wrote in message
> news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...[color=green]
> > It was and it wasn't related to the other post. There were 2 issues and[/color][/color]
if[color=blue]
> I[color=green]
> > could have gotten through either, I probably could have gotten through[/color]
> both.[color=green]
> > The reason I don't post everything is it looks like a huge mess of code
> > coming through the newsgroup. And I just figured it would make things[/color][/color]
more[color=blue][color=green]
> > confusing. Here is the entire recordset created in dreamweaver. It works
> > fine as it is here. I know you code heads may not like dreamweaver but[/color]
> it's[color=green]
> > a huge crutch for those of us that don't have the knowledge to hand code
> > things. It works very well for what I want to do, up until I want to[/color][/color]
give[color=blue]
> an[color=green]
> > extra effort to make things better. For this project I have to use[/color][/color]
Access[color=blue][color=green]
> > 2002. I don't like it, but that's not my choice. I have a music database
> > that users can search. I get titles and artists from many many sources.[/color]
> They[color=green]
> > all choose to spell titles and artists their own way. That's a problem.[/color][/color]
In[color=blue][color=green]
> > an effort to make it easier on the end users, I want to remove common[/color]
> words[color=green]
> > and punctuation that varies. That includes "'", """, ",", "/", " ", "&",
> > "the", and "and". If I remove those characters from both terms, it[/color][/color]
creates[color=blue]
> a[color=green]
> > much better chance of relevant search results. I've done this with SQL
> > stored procedures and it works great. Now I have to do this with SQL in[/color]
> ASP[color=green]
> > and I'm having a lot of syntax problems. I appreciate everyone's help!!![/color][/color]
I[color=blue][color=green]
> > thought I was trying to make it easier on everyone and I guess I made it
> > more confusing. Sorry!
> >
> > I only have to remove those characters from titles and artists fields.[/color][/color]
The[color=blue][color=green]
> > other fields I have control over the data. OK... now how do I accomplish
> > this feat?
> > thanks!
> >
> > <%
> > Dim rsResults__T
> > rsResults__T = "%"
> > If (Request("title") <> "") Then
> > rsResults__T = Request("title")
> > End If
> > %>
> > <%
> > Dim rsResults__A
> > rsResults__A = "%"
> > If (Request("artist") <> "") Then
> > rsResults__A = Request("artist")
> > End If
> > %>
> > <%
> > Dim rsResults__C
> > rsResults__C = "%"
> > If (Request("category") <> "") Then
> > rsResults__C = Request("category")
> > End If
> > %>
> > <%
> > Dim rsResults__TY
> > rsResults__TY = "%"
> > If (Request("type") <> "") Then
> > rsResults__TY = Request("type")
> > End If
> > %>
> > <%
> > Dim rsResults__M
> > rsResults__M = "%"
> > If (Request("manuf") <> "") Then
> > rsResults__M = Request("manuf")
> > End If
> > %>
> > <%
> > Dim rsResults__SA
> > rsResults__SA = "%"
> > If (Request("singleartist") <> "") Then
> > rsResults__SA = Request("singleartist")
> > End If
> > %>
> > <%
> > Dim rsResults
> > Dim rsResults_numRows
> >
> > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
> > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
> > INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber[/color][/color]
WHERE[color=blue][color=green]
> > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") + "'[/color][/color]
+[color=blue][color=green]
> > '%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A, "'",
> > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE '" +
> > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
> > Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist[/color][/color]
LIKE[color=blue][color=green]
> > '" + Replace(rsResults__SA, "'", "''") + "')"
> > rsResults.CursorType = 0
> > rsResults.CursorLocation = 2
> > rsResults.LockType = 1
> > rsResults.Open()
> >
> > rsResults_numRows = 0
> > %>
> >
> > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > "shank" <shank@tampabay.rr.com> wrote in message
> > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > 1) I'm getting this error: Syntax error (missing operator) in query
> > > > expression on the below statement. Can I get some advice.
> > > >
> > > > 2) I searched ASPFAQ and came up blank. Where can find the "rules"[/color][/color][/color]
for[color=blue][color=green][color=darkred]
> > > when
> > > > and how to use single quotes and double quotes in ASP?
> > > >
> > > > thanks!
> > > > ----------------------
> > > > SQL = SQL & "WHERE '" &
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > Title","'",""),",",""),".",""),"[/color]
> > ",""),"the",""),"and",""),"&",""),"/","")[color=darkred]
> > > &
> > > > "' LIKE '%' '" & T & "' '%' "
> > > >
> > >
> > > This appears to be related to your other "syntax error" post. If so,[/color][/color][/color]
it[color=blue][color=green]
> > may[color=darkred]
> > > have been better to post a follow-up to that thread. Given that[/color][/color][/color]
context,[color=blue][color=green]
> > it[color=darkred]
> > > appears that you're attempting to eliminate false positives from your
> > > searches by discluding common words and punctuations. If this is the[/color][/color]
> case,[color=green][color=darkred]
> > > perhaps it would be easier to remove those items from the search term
> > > instead of attempting to remove them from the GenKTitles.Title column[/color][/color][/color]
in[color=blue][color=green][color=darkred]
> > > your database. If you took this approach you could make use of a[/color][/color][/color]
regular[color=blue][color=green][color=darkred]
> > > expression to "scrub" the search term prior to constructing the SQL
> > > statement. Also, please consider using a stored procedure (or[/color]
> > parameterized[color=darkred]
> > > query depending on your database environment) instead of dynamically
> > > constructing the SQL statement. Also, in the future, please provide
> > > database, version, DDL, sample data and desired output/results. Here's[/color][/color]
> are[color=green][color=darkred]
> > > some guidelines
> > >
> > > http://aspfaq.com/5000
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Steven Burn
Guest
 
Posts: n/a
#16: Jul 19 '05

re: Syntax error (missing operator) in query expression


Writing a function is fairly simple......

Function ReplaceThis(sWhat)
'// Though not necessary, I tend to lcase
'// the string before doing anything with it
'// as it makes it easier to work with when
'// you want to replace the text, regardless
'// of whether it has upper or lowercase text

ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
End Function

Then in your page, you'd simply use;

Response.Write ReplaceThis("The dog went over the hill")

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"shank" <shank@tampabay.rr.com> wrote in message
news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...[color=blue]
> Thanks to all, but if I can't get past a few syntax issues, I'll never get
> past creating a function.
>
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...[color=green]
> > I'm certainly no expert but IMHO.......
> >
> > Suggestion #1. Use a regular expression to do the replacing for you
> >
> > This makes for much cleaner, and easier to read code. If you'd rather[/color][/color]
not[color=blue][color=green]
> > use a RegExp for whatever reason, stick to a max of 2 "Replace's" per
> > line....
> >
> > Suggestion #2. Use a function that contains suggestion #1
> >
> > By using a function to do the replacing, it allows you to simply use;
> >
> > Response.Write ReplaceThis(TheString)
> >
> > ... instead of ...
> >
> > Response.Write Replace(Replace(Replace.... etc etc etc
> >
> > Hint:
> >
> > Function ReplaceThis(sWhat)
> > '// RegExp or whatever, code goes here.....
> > End Function
> >
> > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to write[/color]
> the[color=green]
> > code for you....
> >
> > As has been mentioned by Bob, they screw up virtually everything.... tis
> > much easier (and quicker) to learn how to hand code it yourself (hint:
> > aspfaq.com ;o)) using Notepad or some other text editor (just make sure[/color]
> you[color=green]
> > stay away from editors such as MS Word etc, if going this route as[/color][/color]
they're[color=blue]
> a[color=green]
> > royal pain in the backside....).
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> >
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > It was and it wasn't related to the other post. There were 2 issues[/color][/color][/color]
and[color=blue]
> if[color=green]
> > I[color=darkred]
> > > could have gotten through either, I probably could have gotten through[/color]
> > both.[color=darkred]
> > > The reason I don't post everything is it looks like a huge mess of[/color][/color][/color]
code[color=blue][color=green][color=darkred]
> > > coming through the newsgroup. And I just figured it would make things[/color][/color]
> more[color=green][color=darkred]
> > > confusing. Here is the entire recordset created in dreamweaver. It[/color][/color][/color]
works[color=blue][color=green][color=darkred]
> > > fine as it is here. I know you code heads may not like dreamweaver but[/color]
> > it's[color=darkred]
> > > a huge crutch for those of us that don't have the knowledge to hand[/color][/color][/color]
code[color=blue][color=green][color=darkred]
> > > things. It works very well for what I want to do, up until I want to[/color][/color]
> give[color=green]
> > an[color=darkred]
> > > extra effort to make things better. For this project I have to use[/color][/color]
> Access[color=green][color=darkred]
> > > 2002. I don't like it, but that's not my choice. I have a music[/color][/color][/color]
database[color=blue][color=green][color=darkred]
> > > that users can search. I get titles and artists from many many[/color][/color][/color]
sources.[color=blue][color=green]
> > They[color=darkred]
> > > all choose to spell titles and artists their own way. That's a[/color][/color][/color]
problem.[color=blue]
> In[color=green][color=darkred]
> > > an effort to make it easier on the end users, I want to remove common[/color]
> > words[color=darkred]
> > > and punctuation that varies. That includes "'", """, ",", "/", " ",[/color][/color][/color]
"&",[color=blue][color=green][color=darkred]
> > > "the", and "and". If I remove those characters from both terms, it[/color][/color]
> creates[color=green]
> > a[color=darkred]
> > > much better chance of relevant search results. I've done this with SQL
> > > stored procedures and it works great. Now I have to do this with SQL[/color][/color][/color]
in[color=blue][color=green]
> > ASP[color=darkred]
> > > and I'm having a lot of syntax problems. I appreciate everyone's[/color][/color][/color]
help!!![color=blue]
> I[color=green][color=darkred]
> > > thought I was trying to make it easier on everyone and I guess I made[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > more confusing. Sorry!
> > >
> > > I only have to remove those characters from titles and artists fields.[/color][/color]
> The[color=green][color=darkred]
> > > other fields I have control over the data. OK... now how do I[/color][/color][/color]
accomplish[color=blue][color=green][color=darkred]
> > > this feat?
> > > thanks!
> > >
> > > <%
> > > Dim rsResults__T
> > > rsResults__T = "%"
> > > If (Request("title") <> "") Then
> > > rsResults__T = Request("title")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults__A
> > > rsResults__A = "%"
> > > If (Request("artist") <> "") Then
> > > rsResults__A = Request("artist")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults__C
> > > rsResults__C = "%"
> > > If (Request("category") <> "") Then
> > > rsResults__C = Request("category")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults__TY
> > > rsResults__TY = "%"
> > > If (Request("type") <> "") Then
> > > rsResults__TY = Request("type")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults__M
> > > rsResults__M = "%"
> > > If (Request("manuf") <> "") Then
> > > rsResults__M = Request("manuf")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults__SA
> > > rsResults__SA = "%"
> > > If (Request("singleartist") <> "") Then
> > > rsResults__SA = Request("singleartist")
> > > End If
> > > %>
> > > <%
> > > Dim rsResults
> > > Dim rsResults_numRows
> > >
> > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,[/color][/color][/color]
GenKStock.Label,[color=blue][color=green][color=darkred]
> > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM[/color][/color][/color]
GenKStock[color=blue][color=green][color=darkred]
> > > INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber[/color][/color]
> WHERE[color=green][color=darkred]
> > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") +[/color][/color][/color]
"'[color=blue]
> +[color=green][color=darkred]
> > > '%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A,[/color][/color][/color]
"'",[color=blue][color=green][color=darkred]
> > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE '"[/color][/color][/color]
+[color=blue][color=green][color=darkred]
> > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
> > > Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist[/color][/color]
> LIKE[color=green][color=darkred]
> > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > rsResults.CursorType = 0
> > > rsResults.CursorLocation = 2
> > > rsResults.LockType = 1
> > > rsResults.Open()
> > >
> > > rsResults_numRows = 0
> > > %>
> > >
> > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > 1) I'm getting this error: Syntax error (missing operator) in[/color][/color][/color]
query[color=blue][color=green][color=darkred]
> > > > > expression on the below statement. Can I get some advice.
> > > > >
> > > > > 2) I searched ASPFAQ and came up blank. Where can find the "rules"[/color][/color]
> for[color=green][color=darkred]
> > > > when
> > > > > and how to use single quotes and double quotes in ASP?
> > > > >
> > > > > thanks!
> > > > > ----------------------
> > > > > SQL = SQL & "WHERE '" &
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > > Title","'",""),",",""),".",""),"
> > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > &
> > > > > "' LIKE '%' '" & T & "' '%' "
> > > > >
> > > >
> > > > This appears to be related to your other "syntax error" post. If so,[/color][/color]
> it[color=green][color=darkred]
> > > may
> > > > have been better to post a follow-up to that thread. Given that[/color][/color]
> context,[color=green][color=darkred]
> > > it
> > > > appears that you're attempting to eliminate false positives from[/color][/color][/color]
your[color=blue][color=green][color=darkred]
> > > > searches by discluding common words and punctuations. If this is the[/color]
> > case,[color=darkred]
> > > > perhaps it would be easier to remove those items from the search[/color][/color][/color]
term[color=blue][color=green][color=darkred]
> > > > instead of attempting to remove them from the GenKTitles.Title[/color][/color][/color]
column[color=blue]
> in[color=green][color=darkred]
> > > > your database. If you took this approach you could make use of a[/color][/color]
> regular[color=green][color=darkred]
> > > > expression to "scrub" the search term prior to constructing the SQL
> > > > statement. Also, please consider using a stored procedure (or
> > > parameterized
> > > > query depending on your database environment) instead of dynamically
> > > > constructing the SQL statement. Also, in the future, please provide
> > > > database, version, DDL, sample data and desired output/results.[/color][/color][/color]
Here's[color=blue][color=green]
> > are[color=darkred]
> > > > some guidelines
> > > >
> > > > http://aspfaq.com/5000
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


shank
Guest
 
Posts: n/a
#17: Jul 19 '05

re: Syntax error (missing operator) in query expression


I really like the idea of the function, but having problems with syntax
again. I'm starting simple by removing the apostrophes.

<%
Function ReplaceThis(sWhat)
ReplaceThis = Replace(UCase(sWhat), "'", "")
End Function
%>

I'm just including the portion o fthe WHERE clause where I'm experimenting.

WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
ReplaceThis(rsResults__T) + "' + '%')

The SQL to my page is....
SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist, GenKStock.SoftHard,
GenKStock.Category, GenKStock.Type, GenKStock.Label, GenKStock.Description,
GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title, GenKTitles.Artist,
GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE LIKE '%'
+ 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
(GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
(GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER BY
OrderNo ASC

The function ReplaceThis is working fine on this: ReplaceThis(rsResults__T)
But not on this: ReplaceThis("GenKTitles.Title")
I'm getting results that match *aint* but not *ain't*
What am I missing?
thanks for the function!!!

"Steven Burn" <pvt@noyb.com> wrote in message
news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...[color=blue]
> Writing a function is fairly simple......
>
> Function ReplaceThis(sWhat)
> '// Though not necessary, I tend to lcase
> '// the string before doing anything with it
> '// as it makes it easier to work with when
> '// you want to replace the text, regardless
> '// of whether it has upper or lowercase text
>
> ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> End Function
>
> Then in your page, you'd simply use;
>
> Response.Write ReplaceThis("The dog went over the hill")
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
>
> "shank" <shank@tampabay.rr.com> wrote in message
> news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...[color=green]
> > Thanks to all, but if I can't get past a few syntax issues, I'll never[/color][/color]
get[color=blue][color=green]
> > past creating a function.
> >
> > "Steven Burn" <pvt@noyb.com> wrote in message
> > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > I'm certainly no expert but IMHO.......
> > >
> > > Suggestion #1. Use a regular expression to do the replacing for you
> > >
> > > This makes for much cleaner, and easier to read code. If you'd rather[/color][/color]
> not[color=green][color=darkred]
> > > use a RegExp for whatever reason, stick to a max of 2 "Replace's" per
> > > line....
> > >
> > > Suggestion #2. Use a function that contains suggestion #1
> > >
> > > By using a function to do the replacing, it allows you to simply use;
> > >
> > > Response.Write ReplaceThis(TheString)
> > >
> > > ... instead of ...
> > >
> > > Response.Write Replace(Replace(Replace.... etc etc etc
> > >
> > > Hint:
> > >
> > > Function ReplaceThis(sWhat)
> > > '// RegExp or whatever, code goes here.....
> > > End Function
> > >
> > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to[/color][/color][/color]
write[color=blue][color=green]
> > the[color=darkred]
> > > code for you....
> > >
> > > As has been mentioned by Bob, they screw up virtually everything....[/color][/color][/color]
tis[color=blue][color=green][color=darkred]
> > > much easier (and quicker) to learn how to hand code it yourself (hint:
> > > aspfaq.com ;o)) using Notepad or some other text editor (just make[/color][/color][/color]
sure[color=blue][color=green]
> > you[color=darkred]
> > > stay away from editors such as MS Word etc, if going this route as[/color][/color]
> they're[color=green]
> > a[color=darkred]
> > > royal pain in the backside....).
> > >
> > > --
> > >
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > >
> > > "shank" <shank@tampabay.rr.com> wrote in message
> > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > It was and it wasn't related to the other post. There were 2 issues[/color][/color]
> and[color=green]
> > if[color=darkred]
> > > I
> > > > could have gotten through either, I probably could have gotten[/color][/color][/color]
through[color=blue][color=green][color=darkred]
> > > both.
> > > > The reason I don't post everything is it looks like a huge mess of[/color][/color]
> code[color=green][color=darkred]
> > > > coming through the newsgroup. And I just figured it would make[/color][/color][/color]
things[color=blue][color=green]
> > more[color=darkred]
> > > > confusing. Here is the entire recordset created in dreamweaver. It[/color][/color]
> works[color=green][color=darkred]
> > > > fine as it is here. I know you code heads may not like dreamweaver[/color][/color][/color]
but[color=blue][color=green][color=darkred]
> > > it's
> > > > a huge crutch for those of us that don't have the knowledge to hand[/color][/color]
> code[color=green][color=darkred]
> > > > things. It works very well for what I want to do, up until I want to[/color]
> > give[color=darkred]
> > > an
> > > > extra effort to make things better. For this project I have to use[/color]
> > Access[color=darkred]
> > > > 2002. I don't like it, but that's not my choice. I have a music[/color][/color]
> database[color=green][color=darkred]
> > > > that users can search. I get titles and artists from many many[/color][/color]
> sources.[color=green][color=darkred]
> > > They
> > > > all choose to spell titles and artists their own way. That's a[/color][/color]
> problem.[color=green]
> > In[color=darkred]
> > > > an effort to make it easier on the end users, I want to remove[/color][/color][/color]
common[color=blue][color=green][color=darkred]
> > > words
> > > > and punctuation that varies. That includes "'", """, ",", "/", " ",[/color][/color]
> "&",[color=green][color=darkred]
> > > > "the", and "and". If I remove those characters from both terms, it[/color]
> > creates[color=darkred]
> > > a
> > > > much better chance of relevant search results. I've done this with[/color][/color][/color]
SQL[color=blue][color=green][color=darkred]
> > > > stored procedures and it works great. Now I have to do this with SQL[/color][/color]
> in[color=green][color=darkred]
> > > ASP
> > > > and I'm having a lot of syntax problems. I appreciate everyone's[/color][/color]
> help!!![color=green]
> > I[color=darkred]
> > > > thought I was trying to make it easier on everyone and I guess I[/color][/color][/color]
made[color=blue]
> it[color=green][color=darkred]
> > > > more confusing. Sorry!
> > > >
> > > > I only have to remove those characters from titles and artists[/color][/color][/color]
fields.[color=blue][color=green]
> > The[color=darkred]
> > > > other fields I have control over the data. OK... now how do I[/color][/color]
> accomplish[color=green][color=darkred]
> > > > this feat?
> > > > thanks!
> > > >
> > > > <%
> > > > Dim rsResults__T
> > > > rsResults__T = "%"
> > > > If (Request("title") <> "") Then
> > > > rsResults__T = Request("title")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults__A
> > > > rsResults__A = "%"
> > > > If (Request("artist") <> "") Then
> > > > rsResults__A = Request("artist")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults__C
> > > > rsResults__C = "%"
> > > > If (Request("category") <> "") Then
> > > > rsResults__C = Request("category")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults__TY
> > > > rsResults__TY = "%"
> > > > If (Request("type") <> "") Then
> > > > rsResults__TY = Request("type")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults__M
> > > > rsResults__M = "%"
> > > > If (Request("manuf") <> "") Then
> > > > rsResults__M = Request("manuf")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults__SA
> > > > rsResults__SA = "%"
> > > > If (Request("singleartist") <> "") Then
> > > > rsResults__SA = Request("singleartist")
> > > > End If
> > > > %>
> > > > <%
> > > > Dim rsResults
> > > > Dim rsResults_numRows
> > > >
> > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > rsResults.Source = "SELECT GenKStock.OrderNo,[/color][/color][/color]
GenKStock.SingleArtist,[color=blue][color=green][color=darkred]
> > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,[/color][/color]
> GenKStock.Label,[color=green][color=darkred]
> > > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM[/color][/color]
> GenKStock[color=green][color=darkred]
> > > > INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber[/color]
> > WHERE[color=darkred]
> > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''") +[/color][/color]
> "'[color=green]
> > +[color=darkred]
> > > > '%') AND (GenKTitles.Artist LIKE '%' + '" + Replace(rsResults__A,[/color][/color]
> "'",[color=green][color=darkred]
> > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE[/color][/color][/color]
'"[color=blue]
> +[color=green][color=darkred]
> > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '"[/color][/color][/color]
+[color=blue][color=green][color=darkred]
> > > > Replace(rsResults__TY, "'", "''") + "') AND[/color][/color][/color]
(GenKStock.SingleArtist[color=blue][color=green]
> > LIKE[color=darkred]
> > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > rsResults.CursorType = 0
> > > > rsResults.CursorLocation = 2
> > > > rsResults.LockType = 1
> > > > rsResults.Open()
> > > >
> > > > rsResults_numRows = 0
> > > > %>
> > > >
> > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > 1) I'm getting this error: Syntax error (missing operator) in[/color][/color]
> query[color=green][color=darkred]
> > > > > > expression on the below statement. Can I get some advice.
> > > > > >
> > > > > > 2) I searched ASPFAQ and came up blank. Where can find the[/color][/color][/color]
"rules"[color=blue][color=green]
> > for[color=darkred]
> > > > > when
> > > > > > and how to use single quotes and double quotes in ASP?
> > > > > >
> > > > > > thanks!
> > > > > > ----------------------
> > > > > > SQL = SQL & "WHERE '" &
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > > > Title","'",""),",",""),".",""),"
> > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > &
> > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > >
> > > > >
> > > > > This appears to be related to your other "syntax error" post. If[/color][/color][/color]
so,[color=blue][color=green]
> > it[color=darkred]
> > > > may
> > > > > have been better to post a follow-up to that thread. Given that[/color]
> > context,[color=darkred]
> > > > it
> > > > > appears that you're attempting to eliminate false positives from[/color][/color]
> your[color=green][color=darkred]
> > > > > searches by discluding common words and punctuations. If this is[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > case,
> > > > > perhaps it would be easier to remove those items from the search[/color][/color]
> term[color=green][color=darkred]
> > > > > instead of attempting to remove them from the GenKTitles.Title[/color][/color]
> column[color=green]
> > in[color=darkred]
> > > > > your database. If you took this approach you could make use of a[/color]
> > regular[color=darkred]
> > > > > expression to "scrub" the search term prior to constructing the[/color][/color][/color]
SQL[color=blue][color=green][color=darkred]
> > > > > statement. Also, please consider using a stored procedure (or
> > > > parameterized
> > > > > query depending on your database environment) instead of[/color][/color][/color]
dynamically[color=blue][color=green][color=darkred]
> > > > > constructing the SQL statement. Also, in the future, please[/color][/color][/color]
provide[color=blue][color=green][color=darkred]
> > > > > database, version, DDL, sample data and desired output/results.[/color][/color]
> Here's[color=green][color=darkred]
> > > are
> > > > > some guidelines
> > > > >
> > > > > http://aspfaq.com/5000
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Bob Barrows [MVP]
Guest
 
Posts: n/a
#18: Jul 19 '05

re: Syntax error (missing operator) in query expression


shank wrote:[color=blue]
> I really like the idea of the function, but having problems with
>
> The SQL to my page is....
> SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]

No it isn't. This is vbscript code that is supposed to result in a valid sql
statement.

Do this to see the actual sql statement being sent to the database:

Response.Write SQL

We NEED to see the result of this! We have no hope of figuring out what your
problem is without seeing it!

Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Steven Burn
Guest
 
Posts: n/a
#19: Jul 19 '05

re: Syntax error (missing operator) in query expression


Why are you trying to use the function in the SQL query string?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"shank" <shank@tampabay.rr.com> wrote in message
news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...[color=blue]
> I really like the idea of the function, but having problems with syntax
> again. I'm starting simple by removing the apostrophes.
>
> <%
> Function ReplaceThis(sWhat)
> ReplaceThis = Replace(UCase(sWhat), "'", "")
> End Function
> %>
>
> I'm just including the portion o fthe WHERE clause where I'm[/color]
experimenting.[color=blue]
>
> WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> ReplaceThis(rsResults__T) + "' + '%')
>
> The SQL to my page is....
> SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
GenKStock.SoftHard,[color=blue]
> GenKStock.Category, GenKStock.Type, GenKStock.Label,[/color]
GenKStock.Description,[color=blue]
> GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,[/color]
GenKTitles.Artist,[color=blue]
> GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE LIKE[/color]
'%'[color=blue]
> + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER BY
> OrderNo ASC
>
> The function ReplaceThis is working fine on this:[/color]
ReplaceThis(rsResults__T)[color=blue]
> But not on this: ReplaceThis("GenKTitles.Title")
> I'm getting results that match *aint* but not *ain't*
> What am I missing?
> thanks for the function!!!
>
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...[color=green]
> > Writing a function is fairly simple......
> >
> > Function ReplaceThis(sWhat)
> > '// Though not necessary, I tend to lcase
> > '// the string before doing anything with it
> > '// as it makes it easier to work with when
> > '// you want to replace the text, regardless
> > '// of whether it has upper or lowercase text
> >
> > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > End Function
> >
> > Then in your page, you'd simply use;
> >
> > Response.Write ReplaceThis("The dog went over the hill")
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> >
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...[color=darkred]
> > > Thanks to all, but if I can't get past a few syntax issues, I'll never[/color][/color]
> get[color=green][color=darkred]
> > > past creating a function.
> > >
> > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > I'm certainly no expert but IMHO.......
> > > >
> > > > Suggestion #1. Use a regular expression to do the replacing for you
> > > >
> > > > This makes for much cleaner, and easier to read code. If you'd[/color][/color][/color]
rather[color=blue][color=green]
> > not[color=darkred]
> > > > use a RegExp for whatever reason, stick to a max of 2 "Replace's"[/color][/color][/color]
per[color=blue][color=green][color=darkred]
> > > > line....
> > > >
> > > > Suggestion #2. Use a function that contains suggestion #1
> > > >
> > > > By using a function to do the replacing, it allows you to simply[/color][/color][/color]
use;[color=blue][color=green][color=darkred]
> > > >
> > > > Response.Write ReplaceThis(TheString)
> > > >
> > > > ... instead of ...
> > > >
> > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > >
> > > > Hint:
> > > >
> > > > Function ReplaceThis(sWhat)
> > > > '// RegExp or whatever, code goes here.....
> > > > End Function
> > > >
> > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to[/color][/color]
> write[color=green][color=darkred]
> > > the
> > > > code for you....
> > > >
> > > > As has been mentioned by Bob, they screw up virtually everything....[/color][/color]
> tis[color=green][color=darkred]
> > > > much easier (and quicker) to learn how to hand code it yourself[/color][/color][/color]
(hint:[color=blue][color=green][color=darkred]
> > > > aspfaq.com ;o)) using Notepad or some other text editor (just make[/color][/color]
> sure[color=green][color=darkred]
> > > you
> > > > stay away from editors such as MS Word etc, if going this route as[/color]
> > they're[color=darkred]
> > > a
> > > > royal pain in the backside....).
> > > >
> > > > --
> > > >
> > > > Regards
> > > >
> > > > Steven Burn
> > > > Ur I.T. Mate Group
> > > > www.it-mate.co.uk
> > > >
> > > > Keeping it FREE!
> > > >
> > > >
> > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > It was and it wasn't related to the other post. There were 2[/color][/color][/color]
issues[color=blue][color=green]
> > and[color=darkred]
> > > if
> > > > I
> > > > > could have gotten through either, I probably could have gotten[/color][/color]
> through[color=green][color=darkred]
> > > > both.
> > > > > The reason I don't post everything is it looks like a huge mess of[/color]
> > code[color=darkred]
> > > > > coming through the newsgroup. And I just figured it would make[/color][/color]
> things[color=green][color=darkred]
> > > more
> > > > > confusing. Here is the entire recordset created in dreamweaver. It[/color]
> > works[color=darkred]
> > > > > fine as it is here. I know you code heads may not like dreamweaver[/color][/color]
> but[color=green][color=darkred]
> > > > it's
> > > > > a huge crutch for those of us that don't have the knowledge to[/color][/color][/color]
hand[color=blue][color=green]
> > code[color=darkred]
> > > > > things. It works very well for what I want to do, up until I want[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > give
> > > > an
> > > > > extra effort to make things better. For this project I have to use
> > > Access
> > > > > 2002. I don't like it, but that's not my choice. I have a music[/color]
> > database[color=darkred]
> > > > > that users can search. I get titles and artists from many many[/color]
> > sources.[color=darkred]
> > > > They
> > > > > all choose to spell titles and artists their own way. That's a[/color]
> > problem.[color=darkred]
> > > In
> > > > > an effort to make it easier on the end users, I want to remove[/color][/color]
> common[color=green][color=darkred]
> > > > words
> > > > > and punctuation that varies. That includes "'", """, ",", "/", "[/color][/color][/color]
",[color=blue][color=green]
> > "&",[color=darkred]
> > > > > "the", and "and". If I remove those characters from both terms, it
> > > creates
> > > > a
> > > > > much better chance of relevant search results. I've done this with[/color][/color]
> SQL[color=green][color=darkred]
> > > > > stored procedures and it works great. Now I have to do this with[/color][/color][/color]
SQL[color=blue][color=green]
> > in[color=darkred]
> > > > ASP
> > > > > and I'm having a lot of syntax problems. I appreciate everyone's[/color]
> > help!!![color=darkred]
> > > I
> > > > > thought I was trying to make it easier on everyone and I guess I[/color][/color]
> made[color=green]
> > it[color=darkred]
> > > > > more confusing. Sorry!
> > > > >
> > > > > I only have to remove those characters from titles and artists[/color][/color]
> fields.[color=green][color=darkred]
> > > The
> > > > > other fields I have control over the data. OK... now how do I[/color]
> > accomplish[color=darkred]
> > > > > this feat?
> > > > > thanks!
> > > > >
> > > > > <%
> > > > > Dim rsResults__T
> > > > > rsResults__T = "%"
> > > > > If (Request("title") <> "") Then
> > > > > rsResults__T = Request("title")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults__A
> > > > > rsResults__A = "%"
> > > > > If (Request("artist") <> "") Then
> > > > > rsResults__A = Request("artist")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults__C
> > > > > rsResults__C = "%"
> > > > > If (Request("category") <> "") Then
> > > > > rsResults__C = Request("category")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults__TY
> > > > > rsResults__TY = "%"
> > > > > If (Request("type") <> "") Then
> > > > > rsResults__TY = Request("type")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults__M
> > > > > rsResults__M = "%"
> > > > > If (Request("manuf") <> "") Then
> > > > > rsResults__M = Request("manuf")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults__SA
> > > > > rsResults__SA = "%"
> > > > > If (Request("singleartist") <> "") Then
> > > > > rsResults__SA = Request("singleartist")
> > > > > End If
> > > > > %>
> > > > > <%
> > > > > Dim rsResults
> > > > > Dim rsResults_numRows
> > > > >
> > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > rsResults.Source = "SELECT GenKStock.OrderNo,[/color][/color]
> GenKStock.SingleArtist,[color=green][color=darkred]
> > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,[/color]
> > GenKStock.Label,[color=darkred]
> > > > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM[/color]
> > GenKStock[color=darkred]
> > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber
> > > WHERE
> > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'", "''")[/color][/color][/color]
+[color=blue][color=green]
> > "'[color=darkred]
> > > +
> > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +[/color][/color][/color]
Replace(rsResults__A,[color=blue][color=green]
> > "'",[color=darkred]
> > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE[/color][/color]
> '"[color=green]
> > +[color=darkred]
> > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE[/color][/color][/color]
'"[color=blue]
> +[color=green][color=darkred]
> > > > > Replace(rsResults__TY, "'", "''") + "') AND[/color][/color]
> (GenKStock.SingleArtist[color=green][color=darkred]
> > > LIKE
> > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > rsResults.CursorType = 0
> > > > > rsResults.CursorLocation = 2
> > > > > rsResults.LockType = 1
> > > > > rsResults.Open()
> > > > >
> > > > > rsResults_numRows = 0
> > > > > %>
> > > > >
> > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > 1) I'm getting this error: Syntax error (missing operator) in[/color]
> > query[color=darkred]
> > > > > > > expression on the below statement. Can I get some advice.
> > > > > > >
> > > > > > > 2) I searched ASPFAQ and came up blank. Where can find the[/color][/color]
> "rules"[color=green][color=darkred]
> > > for
> > > > > > when
> > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > >
> > > > > > > thanks!
> > > > > > > ----------------------
> > > > > > > SQL = SQL & "WHERE '" &
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > > > > Title","'",""),",",""),".",""),"
> > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > &
> > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > >
> > > > > >
> > > > > > This appears to be related to your other "syntax error" post. If[/color][/color]
> so,[color=green][color=darkred]
> > > it
> > > > > may
> > > > > > have been better to post a follow-up to that thread. Given that
> > > context,
> > > > > it
> > > > > > appears that you're attempting to eliminate false positives from[/color]
> > your[color=darkred]
> > > > > > searches by discluding common words and punctuations. If this is[/color][/color]
> the[color=green][color=darkred]
> > > > case,
> > > > > > perhaps it would be easier to remove those items from the search[/color]
> > term[color=darkred]
> > > > > > instead of attempting to remove them from the GenKTitles.Title[/color]
> > column[color=darkred]
> > > in
> > > > > > your database. If you took this approach you could make use of a
> > > regular
> > > > > > expression to "scrub" the search term prior to constructing the[/color][/color]
> SQL[color=green][color=darkred]
> > > > > > statement. Also, please consider using a stored procedure (or
> > > > > parameterized
> > > > > > query depending on your database environment) instead of[/color][/color]
> dynamically[color=green][color=darkred]
> > > > > > constructing the SQL statement. Also, in the future, please[/color][/color]
> provide[color=green][color=darkred]
> > > > > > database, version, DDL, sample data and desired output/results.[/color]
> > Here's[color=darkred]
> > > > are
> > > > > > some guidelines
> > > > > >
> > > > > > http://aspfaq.com/5000
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


shank
Guest
 
Posts: n/a
#20: Jul 19 '05

re: Syntax error (missing operator) in query expression


This is my code to build the recordset...
<%
Dim rsResults
Dim rsResults_numRows

Set rsResults = Server.CreateObject("ADODB.Recordset")
rsResults.ActiveConnection = MM_GenKAccess_STRING
rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE
( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
ReplaceThis(rsResults__T) + "' + '%') AND (GenKTitles.Artist LIKE '%' + '"
+ Replace(rsResults__A, "'", "''") + "' + '%') AND (GenKStock.Category
LIKE '" + Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf LIKE
'" + Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist LIKE
'" + Replace(rsResults__SA, "'", "''") + "') ORDER BY " +
Replace(rsResults__sql_orderby, "'", "''") + ""
rsResults.CursorType = 0
rsResults.CursorLocation = 2
rsResults.LockType = 1
rsResults.Open()

rsResults_numRows = 0
%>

Then, down in the HTML I have this code: SQL = <%=rsResults.Source%>

Which gives me this: SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE (
GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' +
'%' + '%') AND (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%')
AND (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER BY
OrderNo ASC

Response.write SQL gives me nothing because there is no variable named SQL.
This is response.write SQL: <%=Response.Write(SQL)%> (gives me no results)
Sorry if I don't understand what you want.

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uXz9OFafEHA.236@tk2msftngp13.phx.gbl...[color=blue]
> shank wrote:[color=green]
> > I really like the idea of the function, but having problems with
> >
> > The SQL to my page is....
> > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
>
> No it isn't. This is vbscript code that is supposed to result in a valid[/color]
sql[color=blue]
> statement.
>
> Do this to see the actual sql statement being sent to the database:
>
> Response.Write SQL
>
> We NEED to see the result of this! We have no hope of figuring out what[/color]
your[color=blue]
> problem is without seeing it!
>
> Bob Barrows
>
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>[/color]


shank
Guest
 
Posts: n/a
#21: Jul 19 '05

re: Syntax error (missing operator) in query expression


Example: In the data, some variations of the word ain't include: ain't,
aint, aint'
I have no control over what the user searches on, so I have to remove the
apostrophe from what they submit and also the apostrophe that's in the data.
Otherwise I would not get a hit on all 3 variations.

"Steven Burn" <pvt@noyb.com> wrote in message
news:%234EZJHafEHA.2848@TK2MSFTNGP10.phx.gbl...[color=blue]
> Why are you trying to use the function in the SQL query string?
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
>
> "shank" <shank@tampabay.rr.com> wrote in message
> news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...[color=green]
> > I really like the idea of the function, but having problems with syntax
> > again. I'm starting simple by removing the apostrophes.
> >
> > <%
> > Function ReplaceThis(sWhat)
> > ReplaceThis = Replace(UCase(sWhat), "'", "")
> > End Function
> > %>
> >
> > I'm just including the portion o fthe WHERE clause where I'm[/color]
> experimenting.[color=green]
> >
> > WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > ReplaceThis(rsResults__T) + "' + '%')
> >
> > The SQL to my page is....
> > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
> GenKStock.SoftHard,[color=green]
> > GenKStock.Category, GenKStock.Type, GenKStock.Label,[/color]
> GenKStock.Description,[color=green]
> > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,[/color]
> GenKTitles.Artist,[color=green]
> > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE LIKE[/color]
> '%'[color=green]
> > + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> > (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> > (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER BY
> > OrderNo ASC
> >
> > The function ReplaceThis is working fine on this:[/color]
> ReplaceThis(rsResults__T)[color=green]
> > But not on this: ReplaceThis("GenKTitles.Title")
> > I'm getting results that match *aint* but not *ain't*
> > What am I missing?
> > thanks for the function!!!
> >
> > "Steven Burn" <pvt@noyb.com> wrote in message
> > news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Writing a function is fairly simple......
> > >
> > > Function ReplaceThis(sWhat)
> > > '// Though not necessary, I tend to lcase
> > > '// the string before doing anything with it
> > > '// as it makes it easier to work with when
> > > '// you want to replace the text, regardless
> > > '// of whether it has upper or lowercase text
> > >
> > > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > > End Function
> > >
> > > Then in your page, you'd simply use;
> > >
> > > Response.Write ReplaceThis("The dog went over the hill")
> > >
> > > --
> > >
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > >
> > > "shank" <shank@tampabay.rr.com> wrote in message
> > > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...
> > > > Thanks to all, but if I can't get past a few syntax issues, I'll[/color][/color][/color]
never[color=blue][color=green]
> > get[color=darkred]
> > > > past creating a function.
> > > >
> > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > > I'm certainly no expert but IMHO.......
> > > > >
> > > > > Suggestion #1. Use a regular expression to do the replacing for[/color][/color][/color]
you[color=blue][color=green][color=darkred]
> > > > >
> > > > > This makes for much cleaner, and easier to read code. If you'd[/color][/color]
> rather[color=green][color=darkred]
> > > not
> > > > > use a RegExp for whatever reason, stick to a max of 2 "Replace's"[/color][/color]
> per[color=green][color=darkred]
> > > > > line....
> > > > >
> > > > > Suggestion #2. Use a function that contains suggestion #1
> > > > >
> > > > > By using a function to do the replacing, it allows you to simply[/color][/color]
> use;[color=green][color=darkred]
> > > > >
> > > > > Response.Write ReplaceThis(TheString)
> > > > >
> > > > > ... instead of ...
> > > > >
> > > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > > >
> > > > > Hint:
> > > > >
> > > > > Function ReplaceThis(sWhat)
> > > > > '// RegExp or whatever, code goes here.....
> > > > > End Function
> > > > >
> > > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc, to[/color]
> > write[color=darkred]
> > > > the
> > > > > code for you....
> > > > >
> > > > > As has been mentioned by Bob, they screw up virtually[/color][/color][/color]
everything....[color=blue][color=green]
> > tis[color=darkred]
> > > > > much easier (and quicker) to learn how to hand code it yourself[/color][/color]
> (hint:[color=green][color=darkred]
> > > > > aspfaq.com ;o)) using Notepad or some other text editor (just make[/color]
> > sure[color=darkred]
> > > > you
> > > > > stay away from editors such as MS Word etc, if going this route as
> > > they're
> > > > a
> > > > > royal pain in the backside....).
> > > > >
> > > > > --
> > > > >
> > > > > Regards
> > > > >
> > > > > Steven Burn
> > > > > Ur I.T. Mate Group
> > > > > www.it-mate.co.uk
> > > > >
> > > > > Keeping it FREE!
> > > > >
> > > > >
> > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > > It was and it wasn't related to the other post. There were 2[/color][/color]
> issues[color=green][color=darkred]
> > > and
> > > > if
> > > > > I
> > > > > > could have gotten through either, I probably could have gotten[/color]
> > through[color=darkred]
> > > > > both.
> > > > > > The reason I don't post everything is it looks like a huge mess[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > code
> > > > > > coming through the newsgroup. And I just figured it would make[/color]
> > things[color=darkred]
> > > > more
> > > > > > confusing. Here is the entire recordset created in dreamweaver.[/color][/color][/color]
It[color=blue][color=green][color=darkred]
> > > works
> > > > > > fine as it is here. I know you code heads may not like[/color][/color][/color]
dreamweaver[color=blue][color=green]
> > but[color=darkred]
> > > > > it's
> > > > > > a huge crutch for those of us that don't have the knowledge to[/color][/color]
> hand[color=green][color=darkred]
> > > code
> > > > > > things. It works very well for what I want to do, up until I[/color][/color][/color]
want[color=blue]
> to[color=green][color=darkred]
> > > > give
> > > > > an
> > > > > > extra effort to make things better. For this project I have to[/color][/color][/color]
use[color=blue][color=green][color=darkred]
> > > > Access
> > > > > > 2002. I don't like it, but that's not my choice. I have a music
> > > database
> > > > > > that users can search. I get titles and artists from many many
> > > sources.
> > > > > They
> > > > > > all choose to spell titles and artists their own way. That's a
> > > problem.
> > > > In
> > > > > > an effort to make it easier on the end users, I want to remove[/color]
> > common[color=darkred]
> > > > > words
> > > > > > and punctuation that varies. That includes "'", """, ",", "/", "[/color][/color]
> ",[color=green][color=darkred]
> > > "&",
> > > > > > "the", and "and". If I remove those characters from both terms,[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > > creates
> > > > > a
> > > > > > much better chance of relevant search results. I've done this[/color][/color][/color]
with[color=blue][color=green]
> > SQL[color=darkred]
> > > > > > stored procedures and it works great. Now I have to do this with[/color][/color]
> SQL[color=green][color=darkred]
> > > in
> > > > > ASP
> > > > > > and I'm having a lot of syntax problems. I appreciate everyone's
> > > help!!!
> > > > I
> > > > > > thought I was trying to make it easier on everyone and I guess I[/color]
> > made[color=darkred]
> > > it
> > > > > > more confusing. Sorry!
> > > > > >
> > > > > > I only have to remove those characters from titles and artists[/color]
> > fields.[color=darkred]
> > > > The
> > > > > > other fields I have control over the data. OK... now how do I
> > > accomplish
> > > > > > this feat?
> > > > > > thanks!
> > > > > >
> > > > > > <%
> > > > > > Dim rsResults__T
> > > > > > rsResults__T = "%"
> > > > > > If (Request("title") <> "") Then
> > > > > > rsResults__T = Request("title")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults__A
> > > > > > rsResults__A = "%"
> > > > > > If (Request("artist") <> "") Then
> > > > > > rsResults__A = Request("artist")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults__C
> > > > > > rsResults__C = "%"
> > > > > > If (Request("category") <> "") Then
> > > > > > rsResults__C = Request("category")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults__TY
> > > > > > rsResults__TY = "%"
> > > > > > If (Request("type") <> "") Then
> > > > > > rsResults__TY = Request("type")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults__M
> > > > > > rsResults__M = "%"
> > > > > > If (Request("manuf") <> "") Then
> > > > > > rsResults__M = Request("manuf")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults__SA
> > > > > > rsResults__SA = "%"
> > > > > > If (Request("singleartist") <> "") Then
> > > > > > rsResults__SA = Request("singleartist")
> > > > > > End If
> > > > > > %>
> > > > > > <%
> > > > > > Dim rsResults
> > > > > > Dim rsResults_numRows
> > > > > >
> > > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > > rsResults.Source = "SELECT GenKStock.OrderNo,[/color]
> > GenKStock.SingleArtist,[color=darkred]
> > > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > > GenKStock.Label,
> > > > > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM
> > > GenKStock
> > > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo =[/color][/color][/color]
GenKTitles.ItemNumber[color=blue][color=green][color=darkred]
> > > > WHERE
> > > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'",[/color][/color][/color]
"''")[color=blue]
> +[color=green][color=darkred]
> > > "'
> > > > +
> > > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +[/color][/color]
> Replace(rsResults__A,[color=green][color=darkred]
> > > "'",
> > > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf[/color][/color][/color]
LIKE[color=blue][color=green]
> > '"[color=darkred]
> > > +
> > > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE[/color][/color]
> '"[color=green]
> > +[color=darkred]
> > > > > > Replace(rsResults__TY, "'", "''") + "') AND[/color]
> > (GenKStock.SingleArtist[color=darkred]
> > > > LIKE
> > > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > > rsResults.CursorType = 0
> > > > > > rsResults.CursorLocation = 2
> > > > > > rsResults.LockType = 1
> > > > > > rsResults.Open()
> > > > > >
> > > > > > rsResults_numRows = 0
> > > > > > %>
> > > > > >
> > > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > > 1) I'm getting this error: Syntax error (missing operator)[/color][/color][/color]
in[color=blue][color=green][color=darkred]
> > > query
> > > > > > > > expression on the below statement. Can I get some advice.
> > > > > > > >
> > > > > > > > 2) I searched ASPFAQ and came up blank. Where can find the[/color]
> > "rules"[color=darkred]
> > > > for
> > > > > > > when
> > > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > > >
> > > > > > > > thanks!
> > > > > > > > ----------------------
> > > > > > > > SQL = SQL & "WHERE '" &
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > > > > > Title","'",""),",",""),".",""),"
> > > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > > &
> > > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > > >
> > > > > > >
> > > > > > > This appears to be related to your other "syntax error" post.[/color][/color][/color]
If[color=blue][color=green]
> > so,[color=darkred]
> > > > it
> > > > > > may
> > > > > > > have been better to post a follow-up to that thread. Given[/color][/color][/color]
that[color=blue][color=green][color=darkred]
> > > > context,
> > > > > > it
> > > > > > > appears that you're attempting to eliminate false positives[/color][/color][/color]
from[color=blue][color=green][color=darkred]
> > > your
> > > > > > > searches by discluding common words and punctuations. If this[/color][/color][/color]
is[color=blue][color=green]
> > the[color=darkred]
> > > > > case,
> > > > > > > perhaps it would be easier to remove those items from the[/color][/color][/color]
search[color=blue][color=green][color=darkred]
> > > term
> > > > > > > instead of attempting to remove them from the GenKTitles.Title
> > > column
> > > > in
> > > > > > > your database. If you took this approach you could make use of[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > > regular
> > > > > > > expression to "scrub" the search term prior to constructing[/color][/color][/color]
the[color=blue][color=green]
> > SQL[color=darkred]
> > > > > > > statement. Also, please consider using a stored procedure (or
> > > > > > parameterized
> > > > > > > query depending on your database environment) instead of[/color]
> > dynamically[color=darkred]
> > > > > > > constructing the SQL statement. Also, in the future, please[/color]
> > provide[color=darkred]
> > > > > > > database, version, DDL, sample data and desired[/color][/color][/color]
output/results.[color=blue][color=green][color=darkred]
> > > Here's
> > > > > are
> > > > > > > some guidelines
> > > > > > >
> > > > > > > http://aspfaq.com/5000
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Steven Burn
Guest
 
Posts: n/a
#22: Jul 19 '05

re: Syntax error (missing operator) in query expression


He means do a response.write on SQL where SQL is whatever your writing to
the browser

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"shank" <shank@tampabay.rr.com> wrote in message
news:utc0rXafEHA.3632@TK2MSFTNGP09.phx.gbl...[color=blue]
> This is my code to build the recordset...
> <%
> Dim rsResults
> Dim rsResults_numRows
>
> Set rsResults = Server.CreateObject("ADODB.Recordset")
> rsResults.ActiveConnection = MM_GenKAccess_STRING
> rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
> GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
> INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE
> ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> ReplaceThis(rsResults__T) + "' + '%') AND (GenKTitles.Artist LIKE '%' +[/color]
'"[color=blue]
> + Replace(rsResults__A, "'", "''") + "' + '%') AND (GenKStock.Category
> LIKE '" + Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf[/color]
LIKE[color=blue]
> '" + Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type LIKE '" +
> Replace(rsResults__TY, "'", "''") + "') AND (GenKStock.SingleArtist LIKE
> '" + Replace(rsResults__SA, "'", "''") + "') ORDER BY " +
> Replace(rsResults__sql_orderby, "'", "''") + ""
> rsResults.CursorType = 0
> rsResults.CursorLocation = 2
> rsResults.LockType = 1
> rsResults.Open()
>
> rsResults_numRows = 0
> %>
>
> Then, down in the HTML I have this code: SQL = <%=rsResults.Source%>
>
> Which gives me this: SQL = SELECT GenKStock.OrderNo,[/color]
GenKStock.SingleArtist,[color=blue]
> GenKStock.SoftHard, GenKStock.Category, GenKStock.Type, GenKStock.Label,
> GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock
> INNER JOIN GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE (
> GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%'[/color]
+[color=blue]
> '%' + '%') AND (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE[/color]
'%')[color=blue]
> AND (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER[/color]
BY[color=blue]
> OrderNo ASC
>
> Response.write SQL gives me nothing because there is no variable named[/color]
SQL.[color=blue]
> This is response.write SQL: <%=Response.Write(SQL)%> (gives me no results)
> Sorry if I don't understand what you want.
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:uXz9OFafEHA.236@tk2msftngp13.phx.gbl...[color=green]
> > shank wrote:[color=darkred]
> > > I really like the idea of the function, but having problems with
> > >
> > > The SQL to my page is....
> > > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
> >
> > No it isn't. This is vbscript code that is supposed to result in a valid[/color]
> sql[color=green]
> > statement.
> >
> > Do this to see the actual sql statement being sent to the database:
> >
> > Response.Write SQL
> >
> > We NEED to see the result of this! We have no hope of figuring out what[/color]
> your[color=green]
> > problem is without seeing it!
> >
> > Bob Barrows
> >
> >
> > --
> > Microsoft MVP - ASP/ASP.NET
> > Please reply to the newsgroup. This email account is my spam trap so I
> > don't check it very often. If you must reply off-line, then remove the
> > "NO SPAM"
> >
> >[/color]
>
>[/color]


Steven Burn
Guest
 
Posts: n/a
#23: Jul 19 '05

re: Syntax error (missing operator) in query expression


But surely, if it's to be an effective search, you don't want a match on all
variations?. For example, if I search for "some text" on dogpile.com, I'd
expect it to only return results with "some text", not "some' text" or
"sometext" or "some text's" etc

My point being, don't bother trying to account for what the user will or
will not search for as you'll still be trying to figure it out for the next
hundred years or so, and instead, have the user decide what will and will
not be returned.

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"shank" <shank@tampabay.rr.com> wrote in message
news:eiHcbZafEHA.712@TK2MSFTNGP09.phx.gbl...[color=blue]
> Example: In the data, some variations of the word ain't include: ain't,
> aint, aint'
> I have no control over what the user searches on, so I have to remove the
> apostrophe from what they submit and also the apostrophe that's in the[/color]
data.[color=blue]
> Otherwise I would not get a hit on all 3 variations.
>
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:%234EZJHafEHA.2848@TK2MSFTNGP10.phx.gbl...[color=green]
> > Why are you trying to use the function in the SQL query string?
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> >
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > I really like the idea of the function, but having problems with[/color][/color][/color]
syntax[color=blue][color=green][color=darkred]
> > > again. I'm starting simple by removing the apostrophes.
> > >
> > > <%
> > > Function ReplaceThis(sWhat)
> > > ReplaceThis = Replace(UCase(sWhat), "'", "")
> > > End Function
> > > %>
> > >
> > > I'm just including the portion o fthe WHERE clause where I'm[/color]
> > experimenting.[color=darkred]
> > >
> > > WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > > ReplaceThis(rsResults__T) + "' + '%')
> > >
> > > The SQL to my page is....
> > > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
> > GenKStock.SoftHard,[color=darkred]
> > > GenKStock.Category, GenKStock.Type, GenKStock.Label,[/color]
> > GenKStock.Description,[color=darkred]
> > > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,[/color]
> > GenKTitles.Artist,[color=darkred]
> > > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE[/color][/color][/color]
LIKE[color=blue][color=green]
> > '%'[color=darkred]
> > > + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> > > (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> > > (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER[/color][/color][/color]
BY[color=blue][color=green][color=darkred]
> > > OrderNo ASC
> > >
> > > The function ReplaceThis is working fine on this:[/color]
> > ReplaceThis(rsResults__T)[color=darkred]
> > > But not on this: ReplaceThis("GenKTitles.Title")
> > > I'm getting results that match *aint* but not *ain't*
> > > What am I missing?
> > > thanks for the function!!!
> > >
> > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...
> > > > Writing a function is fairly simple......
> > > >
> > > > Function ReplaceThis(sWhat)
> > > > '// Though not necessary, I tend to lcase
> > > > '// the string before doing anything with it
> > > > '// as it makes it easier to work with when
> > > > '// you want to replace the text, regardless
> > > > '// of whether it has upper or lowercase text
> > > >
> > > > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > > > End Function
> > > >
> > > > Then in your page, you'd simply use;
> > > >
> > > > Response.Write ReplaceThis("The dog went over the hill")
> > > >
> > > > --
> > > >
> > > > Regards
> > > >
> > > > Steven Burn
> > > > Ur I.T. Mate Group
> > > > www.it-mate.co.uk
> > > >
> > > > Keeping it FREE!
> > > >
> > > >
> > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...
> > > > > Thanks to all, but if I can't get past a few syntax issues, I'll[/color][/color]
> never[color=green][color=darkred]
> > > get
> > > > > past creating a function.
> > > > >
> > > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > > > I'm certainly no expert but IMHO.......
> > > > > >
> > > > > > Suggestion #1. Use a regular expression to do the replacing for[/color][/color]
> you[color=green][color=darkred]
> > > > > >
> > > > > > This makes for much cleaner, and easier to read code. If you'd[/color]
> > rather[color=darkred]
> > > > not
> > > > > > use a RegExp for whatever reason, stick to a max of 2[/color][/color][/color]
"Replace's"[color=blue][color=green]
> > per[color=darkred]
> > > > > > line....
> > > > > >
> > > > > > Suggestion #2. Use a function that contains suggestion #1
> > > > > >
> > > > > > By using a function to do the replacing, it allows you to simply[/color]
> > use;[color=darkred]
> > > > > >
> > > > > > Response.Write ReplaceThis(TheString)
> > > > > >
> > > > > > ... instead of ...
> > > > > >
> > > > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > > > >
> > > > > > Hint:
> > > > > >
> > > > > > Function ReplaceThis(sWhat)
> > > > > > '// RegExp or whatever, code goes here.....
> > > > > > End Function
> > > > > >
> > > > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc,[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > write
> > > > > the
> > > > > > code for you....
> > > > > >
> > > > > > As has been mentioned by Bob, they screw up virtually[/color][/color]
> everything....[color=green][color=darkred]
> > > tis
> > > > > > much easier (and quicker) to learn how to hand code it yourself[/color]
> > (hint:[color=darkred]
> > > > > > aspfaq.com ;o)) using Notepad or some other text editor (just[/color][/color][/color]
make[color=blue][color=green][color=darkred]
> > > sure
> > > > > you
> > > > > > stay away from editors such as MS Word etc, if going this route[/color][/color][/color]
as[color=blue][color=green][color=darkred]
> > > > they're
> > > > > a
> > > > > > royal pain in the backside....).
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Regards
> > > > > >
> > > > > > Steven Burn
> > > > > > Ur I.T. Mate Group
> > > > > > www.it-mate.co.uk
> > > > > >
> > > > > > Keeping it FREE!
> > > > > >
> > > > > >
> > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > > > It was and it wasn't related to the other post. There were 2[/color]
> > issues[color=darkred]
> > > > and
> > > > > if
> > > > > > I
> > > > > > > could have gotten through either, I probably could have gotten
> > > through
> > > > > > both.
> > > > > > > The reason I don't post everything is it looks like a huge[/color][/color][/color]
mess[color=blue]
> of[color=green][color=darkred]
> > > > code
> > > > > > > coming through the newsgroup. And I just figured it would make
> > > things
> > > > > more
> > > > > > > confusing. Here is the entire recordset created in[/color][/color][/color]
dreamweaver.[color=blue]
> It[color=green][color=darkred]
> > > > works
> > > > > > > fine as it is here. I know you code heads may not like[/color][/color]
> dreamweaver[color=green][color=darkred]
> > > but
> > > > > > it's
> > > > > > > a huge crutch for those of us that don't have the knowledge to[/color]
> > hand[color=darkred]
> > > > code
> > > > > > > things. It works very well for what I want to do, up until I[/color][/color]
> want[color=green]
> > to[color=darkred]
> > > > > give
> > > > > > an
> > > > > > > extra effort to make things better. For this project I have to[/color][/color]
> use[color=green][color=darkred]
> > > > > Access
> > > > > > > 2002. I don't like it, but that's not my choice. I have a[/color][/color][/color]
music[color=blue][color=green][color=darkred]
> > > > database
> > > > > > > that users can search. I get titles and artists from many many
> > > > sources.
> > > > > > They
> > > > > > > all choose to spell titles and artists their own way. That's a
> > > > problem.
> > > > > In
> > > > > > > an effort to make it easier on the end users, I want to remove
> > > common
> > > > > > words
> > > > > > > and punctuation that varies. That includes "'", """, ",", "/",[/color][/color][/color]
"[color=blue][color=green]
> > ",[color=darkred]
> > > > "&",
> > > > > > > "the", and "and". If I remove those characters from both[/color][/color][/color]
terms,[color=blue]
> it[color=green][color=darkred]
> > > > > creates
> > > > > > a
> > > > > > > much better chance of relevant search results. I've done this[/color][/color]
> with[color=green][color=darkred]
> > > SQL
> > > > > > > stored procedures and it works great. Now I have to do this[/color][/color][/color]
with[color=blue][color=green]
> > SQL[color=darkred]
> > > > in
> > > > > > ASP
> > > > > > > and I'm having a lot of syntax problems. I appreciate[/color][/color][/color]
everyone's[color=blue][color=green][color=darkred]
> > > > help!!!
> > > > > I
> > > > > > > thought I was trying to make it easier on everyone and I guess[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > made
> > > > it
> > > > > > > more confusing. Sorry!
> > > > > > >
> > > > > > > I only have to remove those characters from titles and artists
> > > fields.
> > > > > The
> > > > > > > other fields I have control over the data. OK... now how do I
> > > > accomplish
> > > > > > > this feat?
> > > > > > > thanks!
> > > > > > >
> > > > > > > <%
> > > > > > > Dim rsResults__T
> > > > > > > rsResults__T = "%"
> > > > > > > If (Request("title") <> "") Then
> > > > > > > rsResults__T = Request("title")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__A
> > > > > > > rsResults__A = "%"
> > > > > > > If (Request("artist") <> "") Then
> > > > > > > rsResults__A = Request("artist")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__C
> > > > > > > rsResults__C = "%"
> > > > > > > If (Request("category") <> "") Then
> > > > > > > rsResults__C = Request("category")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__TY
> > > > > > > rsResults__TY = "%"
> > > > > > > If (Request("type") <> "") Then
> > > > > > > rsResults__TY = Request("type")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__M
> > > > > > > rsResults__M = "%"
> > > > > > > If (Request("manuf") <> "") Then
> > > > > > > rsResults__M = Request("manuf")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__SA
> > > > > > > rsResults__SA = "%"
> > > > > > > If (Request("singleartist") <> "") Then
> > > > > > > rsResults__SA = Request("singleartist")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults
> > > > > > > Dim rsResults_numRows
> > > > > > >
> > > > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > > > rsResults.Source = "SELECT GenKStock.OrderNo,
> > > GenKStock.SingleArtist,
> > > > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > > > GenKStock.Label,
> > > > > > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM
> > > > GenKStock
> > > > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo =[/color][/color]
> GenKTitles.ItemNumber[color=green][color=darkred]
> > > > > WHERE
> > > > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'",[/color][/color]
> "''")[color=green]
> > +[color=darkred]
> > > > "'
> > > > > +
> > > > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +[/color]
> > Replace(rsResults__A,[color=darkred]
> > > > "'",
> > > > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf[/color][/color]
> LIKE[color=green][color=darkred]
> > > '"
> > > > +
> > > > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type[/color][/color][/color]
LIKE[color=blue][color=green]
> > '"[color=darkred]
> > > +
> > > > > > > Replace(rsResults__TY, "'", "''") + "') AND
> > > (GenKStock.SingleArtist
> > > > > LIKE
> > > > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > > > rsResults.CursorType = 0
> > > > > > > rsResults.CursorLocation = 2
> > > > > > > rsResults.LockType = 1
> > > > > > > rsResults.Open()
> > > > > > >
> > > > > > > rsResults_numRows = 0
> > > > > > > %>
> > > > > > >
> > > > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > 1) I'm getting this error: Syntax error (missing operator)[/color][/color]
> in[color=green][color=darkred]
> > > > query
> > > > > > > > > expression on the below statement. Can I get some advice.
> > > > > > > > >
> > > > > > > > > 2) I searched ASPFAQ and came up blank. Where can find the
> > > "rules"
> > > > > for
> > > > > > > > when
> > > > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > > > >
> > > > > > > > > thanks!
> > > > > > > > > ----------------------
> > > > > > > > > SQL = SQL & "WHERE '" &
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitles.[color=blue][color=green][color=darkred]
> > > > > > > > > Title","'",""),",",""),".",""),"
> > > > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > > > &
> > > > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > > > >
> > > > > > > >
> > > > > > > > This appears to be related to your other "syntax error"[/color][/color][/color]
post.[color=blue]
> If[color=green][color=darkred]
> > > so,
> > > > > it
> > > > > > > may
> > > > > > > > have been better to post a follow-up to that thread. Given[/color][/color]
> that[color=green][color=darkred]
> > > > > context,
> > > > > > > it
> > > > > > > > appears that you're attempting to eliminate false positives[/color][/color]
> from[color=green][color=darkred]
> > > > your
> > > > > > > > searches by discluding common words and punctuations. If[/color][/color][/color]
this[color=blue]
> is[color=green][color=darkred]
> > > the
> > > > > > case,
> > > > > > > > perhaps it would be easier to remove those items from the[/color][/color]
> search[color=green][color=darkred]
> > > > term
> > > > > > > > instead of attempting to remove them from the[/color][/color][/color]
GenKTitles.Title[color=blue][color=green][color=darkred]
> > > > column
> > > > > in
> > > > > > > > your database. If you took this approach you could make use[/color][/color][/color]
of[color=blue]
> a[color=green][color=darkred]
> > > > > regular
> > > > > > > > expression to "scrub" the search term prior to constructing[/color][/color]
> the[color=green][color=darkred]
> > > SQL
> > > > > > > > statement. Also, please consider using a stored procedure[/color][/color][/color]
(or[color=blue][color=green][color=darkred]
> > > > > > > parameterized
> > > > > > > > query depending on your database environment) instead of
> > > dynamically
> > > > > > > > constructing the SQL statement. Also, in the future, please
> > > provide
> > > > > > > > database, version, DDL, sample data and desired[/color][/color]
> output/results.[color=green][color=darkred]
> > > > Here's
> > > > > > are
> > > > > > > > some guidelines
> > > > > > > >
> > > > > > > > http://aspfaq.com/5000
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Bob Lehmann
Guest
 
Posts: n/a
#24: Jul 19 '05

re: Syntax error (missing operator) in query expression


What Steve means is - Why aren't you using it in your IF blocks...
<%
Dim rsResults__A
rsResults__A = "%"
If (Request("artist") <> "") Then
rsResults__A = ReplaceThis(Request("artist"))
End If
%>

Then just use rsResults__A when you build your string fir the SQL, which
will make that code much more readable.

Does GENKTITLES.TITLE contain a " ' "? If it does, then why would you expect
a match?

WTF is this all about? AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND

Bob Lehmann


"shank" <shank@tampabay.rr.com> wrote in message
news:eiHcbZafEHA.712@TK2MSFTNGP09.phx.gbl...[color=blue]
> Example: In the data, some variations of the word ain't include: ain't,
> aint, aint'
> I have no control over what the user searches on, so I have to remove the
> apostrophe from what they submit and also the apostrophe that's in the[/color]
data.[color=blue]
> Otherwise I would not get a hit on all 3 variations.
>
> "Steven Burn" <pvt@noyb.com> wrote in message
> news:%234EZJHafEHA.2848@TK2MSFTNGP10.phx.gbl...[color=green]
> > Why are you trying to use the function in the SQL query string?
> >
> > --
> >
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> >
> > "shank" <shank@tampabay.rr.com> wrote in message
> > news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > I really like the idea of the function, but having problems with[/color][/color][/color]
syntax[color=blue][color=green][color=darkred]
> > > again. I'm starting simple by removing the apostrophes.
> > >
> > > <%
> > > Function ReplaceThis(sWhat)
> > > ReplaceThis = Replace(UCase(sWhat), "'", "")
> > > End Function
> > > %>
> > >
> > > I'm just including the portion o fthe WHERE clause where I'm[/color]
> > experimenting.[color=darkred]
> > >
> > > WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > > ReplaceThis(rsResults__T) + "' + '%')
> > >
> > > The SQL to my page is....
> > > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,[/color]
> > GenKStock.SoftHard,[color=darkred]
> > > GenKStock.Category, GenKStock.Type, GenKStock.Label,[/color]
> > GenKStock.Description,[color=darkred]
> > > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,[/color]
> > GenKTitles.Artist,[color=darkred]
> > > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE[/color][/color][/color]
LIKE[color=blue][color=green]
> > '%'[color=darkred]
> > > + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> > > (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> > > (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%') ORDER[/color][/color][/color]
BY[color=blue][color=green][color=darkred]
> > > OrderNo ASC
> > >
> > > The function ReplaceThis is working fine on this:[/color]
> > ReplaceThis(rsResults__T)[color=darkred]
> > > But not on this: ReplaceThis("GenKTitles.Title")
> > > I'm getting results that match *aint* but not *ain't*
> > > What am I missing?
> > > thanks for the function!!!
> > >
> > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...
> > > > Writing a function is fairly simple......
> > > >
> > > > Function ReplaceThis(sWhat)
> > > > '// Though not necessary, I tend to lcase
> > > > '// the string before doing anything with it
> > > > '// as it makes it easier to work with when
> > > > '// you want to replace the text, regardless
> > > > '// of whether it has upper or lowercase text
> > > >
> > > > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > > > End Function
> > > >
> > > > Then in your page, you'd simply use;
> > > >
> > > > Response.Write ReplaceThis("The dog went over the hill")
> > > >
> > > > --
> > > >
> > > > Regards
> > > >
> > > > Steven Burn
> > > > Ur I.T. Mate Group
> > > > www.it-mate.co.uk
> > > >
> > > > Keeping it FREE!
> > > >
> > > >
> > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...
> > > > > Thanks to all, but if I can't get past a few syntax issues, I'll[/color][/color]
> never[color=green][color=darkred]
> > > get
> > > > > past creating a function.
> > > > >
> > > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > > > I'm certainly no expert but IMHO.......
> > > > > >
> > > > > > Suggestion #1. Use a regular expression to do the replacing for[/color][/color]
> you[color=green][color=darkred]
> > > > > >
> > > > > > This makes for much cleaner, and easier to read code. If you'd[/color]
> > rather[color=darkred]
> > > > not
> > > > > > use a RegExp for whatever reason, stick to a max of 2[/color][/color][/color]
"Replace's"[color=blue][color=green]
> > per[color=darkred]
> > > > > > line....
> > > > > >
> > > > > > Suggestion #2. Use a function that contains suggestion #1
> > > > > >
> > > > > > By using a function to do the replacing, it allows you to simply[/color]
> > use;[color=darkred]
> > > > > >
> > > > > > Response.Write ReplaceThis(TheString)
> > > > > >
> > > > > > ... instead of ...
> > > > > >
> > > > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > > > >
> > > > > > Hint:
> > > > > >
> > > > > > Function ReplaceThis(sWhat)
> > > > > > '// RegExp or whatever, code goes here.....
> > > > > > End Function
> > > > > >
> > > > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc,[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > write
> > > > > the
> > > > > > code for you....
> > > > > >
> > > > > > As has been mentioned by Bob, they screw up virtually[/color][/color]
> everything....[color=green][color=darkred]
> > > tis
> > > > > > much easier (and quicker) to learn how to hand code it yourself[/color]
> > (hint:[color=darkred]
> > > > > > aspfaq.com ;o)) using Notepad or some other text editor (just[/color][/color][/color]
make[color=blue][color=green][color=darkred]
> > > sure
> > > > > you
> > > > > > stay away from editors such as MS Word etc, if going this route[/color][/color][/color]
as[color=blue][color=green][color=darkred]
> > > > they're
> > > > > a
> > > > > > royal pain in the backside....).
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Regards
> > > > > >
> > > > > > Steven Burn
> > > > > > Ur I.T. Mate Group
> > > > > > www.it-mate.co.uk
> > > > > >
> > > > > > Keeping it FREE!
> > > > > >
> > > > > >
> > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > > > It was and it wasn't related to the other post. There were 2[/color]
> > issues[color=darkred]
> > > > and
> > > > > if
> > > > > > I
> > > > > > > could have gotten through either, I probably could have gotten
> > > through
> > > > > > both.
> > > > > > > The reason I don't post everything is it looks like a huge[/color][/color][/color]
mess[color=blue]
> of[color=green][color=darkred]
> > > > code
> > > > > > > coming through the newsgroup. And I just figured it would make
> > > things
> > > > > more
> > > > > > > confusing. Here is the entire recordset created in[/color][/color][/color]
dreamweaver.[color=blue]
> It[color=green][color=darkred]
> > > > works
> > > > > > > fine as it is here. I know you code heads may not like[/color][/color]
> dreamweaver[color=green][color=darkred]
> > > but
> > > > > > it's
> > > > > > > a huge crutch for those of us that don't have the knowledge to[/color]
> > hand[color=darkred]
> > > > code
> > > > > > > things. It works very well for what I want to do, up until I[/color][/color]
> want[color=green]
> > to[color=darkred]
> > > > > give
> > > > > > an
> > > > > > > extra effort to make things better. For this project I have to[/color][/color]
> use[color=green][color=darkred]
> > > > > Access
> > > > > > > 2002. I don't like it, but that's not my choice. I have a[/color][/color][/color]
music[color=blue][color=green][color=darkred]
> > > > database
> > > > > > > that users can search. I get titles and artists from many many
> > > > sources.
> > > > > > They
> > > > > > > all choose to spell titles and artists their own way. That's a
> > > > problem.
> > > > > In
> > > > > > > an effort to make it easier on the end users, I want to remove
> > > common
> > > > > > words
> > > > > > > and punctuation that varies. That includes "'", """, ",", "/",[/color][/color][/color]
"[color=blue][color=green]
> > ",[color=darkred]
> > > > "&",
> > > > > > > "the", and "and". If I remove those characters from both[/color][/color][/color]
terms,[color=blue]
> it[color=green][color=darkred]
> > > > > creates
> > > > > > a
> > > > > > > much better chance of relevant search results. I've done this[/color][/color]
> with[color=green][color=darkred]
> > > SQL
> > > > > > > stored procedures and it works great. Now I have to do this[/color][/color][/color]
with[color=blue][color=green]
> > SQL[color=darkred]
> > > > in
> > > > > > ASP
> > > > > > > and I'm having a lot of syntax problems. I appreciate[/color][/color][/color]
everyone's[color=blue][color=green][color=darkred]
> > > > help!!!
> > > > > I
> > > > > > > thought I was trying to make it easier on everyone and I guess[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > made
> > > > it
> > > > > > > more confusing. Sorry!
> > > > > > >
> > > > > > > I only have to remove those characters from titles and artists
> > > fields.
> > > > > The
> > > > > > > other fields I have control over the data. OK... now how do I
> > > > accomplish
> > > > > > > this feat?
> > > > > > > thanks!
> > > > > > >
> > > > > > > <%
> > > > > > > Dim rsResults__T
> > > > > > > rsResults__T = "%"
> > > > > > > If (Request("title") <> "") Then
> > > > > > > rsResults__T = Request("title")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__A
> > > > > > > rsResults__A = "%"
> > > > > > > If (Request("artist") <> "") Then
> > > > > > > rsResults__A = Request("artist")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__C
> > > > > > > rsResults__C = "%"
> > > > > > > If (Request("category") <> "") Then
> > > > > > > rsResults__C = Request("category")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__TY
> > > > > > > rsResults__TY = "%"
> > > > > > > If (Request("type") <> "") Then
> > > > > > > rsResults__TY = Request("type")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__M
> > > > > > > rsResults__M = "%"
> > > > > > > If (Request("manuf") <> "") Then
> > > > > > > rsResults__M = Request("manuf")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults__SA
> > > > > > > rsResults__SA = "%"
> > > > > > > If (Request("singleartist") <> "") Then
> > > > > > > rsResults__SA = Request("singleartist")
> > > > > > > End If
> > > > > > > %>
> > > > > > > <%
> > > > > > > Dim rsResults
> > > > > > > Dim rsResults_numRows
> > > > > > >
> > > > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > > > rsResults.Source = "SELECT GenKStock.OrderNo,
> > > GenKStock.SingleArtist,
> > > > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > > > GenKStock.Label,
> > > > > > > GenKStock.Description, GenKStock.Manuf, GenKTitles.ItemNumber,
> > > > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files FROM
> > > > GenKStock
> > > > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo =[/color][/color]
> GenKTitles.ItemNumber[color=green][color=darkred]
> > > > > WHERE
> > > > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'",[/color][/color]
> "''")[color=green]
> > +[color=darkred]
> > > > "'
> > > > > +
> > > > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +[/color]
> > Replace(rsResults__A,[color=darkred]
> > > > "'",
> > > > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > > > Replace(rsResults__C, "'", "''") + "') AND (GenKStock.Manuf[/color][/color]
> LIKE[color=green][color=darkred]
> > > '"
> > > > +
> > > > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type[/color][/color][/color]
LIKE[color=blue][color=green]
> > '"[color=darkred]
> > > +
> > > > > > > Replace(rsResults__TY, "'", "''") + "') AND
> > > (GenKStock.SingleArtist
> > > > > LIKE
> > > > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > > > rsResults.CursorType = 0
> > > > > > > rsResults.CursorLocation = 2
> > > > > > > rsResults.LockType = 1
> > > > > > > rsResults.Open()
> > > > > > >
> > > > > > > rsResults_numRows = 0
> > > > > > > %>
> > > > > > >
> > > > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > 1) I'm getting this error: Syntax error (missing operator)[/color][/color]
> in[color=green][color=darkred]
> > > > query
> > > > > > > > > expression on the below statement. Can I get some advice.
> > > > > > > > >
> > > > > > > > > 2) I searched ASPFAQ and came up blank. Where can find the
> > > "rules"
> > > > > for
> > > > > > > > when
> > > > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > > > >
> > > > > > > > > thanks!
> > > > > > > > > ----------------------
> > > > > > > > > SQL = SQL & "WHERE '" &
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color]
> REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitle[/color]
s.[color=blue][color=green][color=darkred]
> > > > > > > > > Title","'",""),",",""),".",""),"
> > > > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > > > &
> > > > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > > > >
> > > > > > > >
> > > > > > > > This appears to be related to your other "syntax error"[/color][/color][/color]
post.[color=blue]
> If[color=green][color=darkred]
> > > so,
> > > > > it
> > > > > > > may
> > > > > > > > have been better to post a follow-up to that thread. Given[/color][/color]
> that[color=green][color=darkred]
> > > > > context,
> > > > > > > it
> > > > > > > > appears that you're attempting to eliminate false positives[/color][/color]
> from[color=green][color=darkred]
> > > > your
> > > > > > > > searches by discluding common words and punctuations. If[/color][/color][/color]
this[color=blue]
> is[color=green][color=darkred]
> > > the
> > > > > > case,
> > > > > > > > perhaps it would be easier to remove those items from the[/color][/color]
> search[color=green][color=darkred]
> > > > term
> > > > > > > > instead of attempting to remove them from the[/color][/color][/color]
GenKTitles.Title[color=blue][color=green][color=darkred]
> > > > column
> > > > > in
> > > > > > > > your database. If you took this approach you could make use[/color][/color][/color]
of[color=blue]
> a[color=green][color=darkred]
> > > > > regular
> > > > > > > > expression to "scrub" the search term prior to constructing[/color][/color]
> the[color=green][color=darkred]
> > > SQL
> > > > > > > > statement. Also, please consider using a stored procedure[/color][/color][/color]
(or[color=blue][color=green][color=darkred]
> > > > > > > parameterized
> > > > > > > > query depending on your database environment) instead of
> > > dynamically
> > > > > > > > constructing the SQL statement. Also, in the future, please
> > > provide
> > > > > > > > database, version, DDL, sample data and desired[/color][/color]
> output/results.[color=green][color=darkred]
> > > > Here's
> > > > > > are
> > > > > > > > some guidelines
> > > > > > > >
> > > > > > > > http://aspfaq.com/5000
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Steven Burn
Guest
 
Posts: n/a
#25: Jul 19 '05

re: Syntax error (missing operator) in query expression


> What Steve means is - Why aren't you using it in your IF blocks...

hehe, cheers Bob ;o) (think I'm having a blonde day today)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
news:Om$iomafEHA.3536@TK2MSFTNGP12.phx.gbl...[color=blue]
> What Steve means is - Why aren't you using it in your IF blocks...
> <%
> Dim rsResults__A
> rsResults__A = "%"
> If (Request("artist") <> "") Then
> rsResults__A = ReplaceThis(Request("artist"))
> End If
> %>
>
> Then just use rsResults__A when you build your string fir the SQL, which
> will make that code much more readable.
>
> Does GENKTITLES.TITLE contain a " ' "? If it does, then why would you[/color]
expect[color=blue]
> a match?
>
> WTF is this all about? AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
>
> Bob Lehmann
>
>
> "shank" <shank@tampabay.rr.com> wrote in message
> news:eiHcbZafEHA.712@TK2MSFTNGP09.phx.gbl...[color=green]
> > Example: In the data, some variations of the word ain't include: ain't,
> > aint, aint'
> > I have no control over what the user searches on, so I have to remove[/color][/color]
the[color=blue][color=green]
> > apostrophe from what they submit and also the apostrophe that's in the[/color]
> data.[color=green]
> > Otherwise I would not get a hit on all 3 variations.
> >
> > "Steven Burn" <pvt@noyb.com> wrote in message
> > news:%234EZJHafEHA.2848@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Why are you trying to use the function in the SQL query string?
> > >
> > > --
> > >
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > >
> > > "shank" <shank@tampabay.rr.com> wrote in message
> > > news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...
> > > > I really like the idea of the function, but having problems with[/color][/color]
> syntax[color=green][color=darkred]
> > > > again. I'm starting simple by removing the apostrophes.
> > > >
> > > > <%
> > > > Function ReplaceThis(sWhat)
> > > > ReplaceThis = Replace(UCase(sWhat), "'", "")
> > > > End Function
> > > > %>
> > > >
> > > > I'm just including the portion o fthe WHERE clause where I'm
> > > experimenting.
> > > >
> > > > WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > > > ReplaceThis(rsResults__T) + "' + '%')
> > > >
> > > > The SQL to my page is....
> > > > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> > > GenKStock.SoftHard,
> > > > GenKStock.Category, GenKStock.Type, GenKStock.Label,
> > > GenKStock.Description,
> > > > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,
> > > GenKTitles.Artist,
> > > > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > > > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE[/color][/color]
> LIKE[color=green][color=darkred]
> > > '%'
> > > > + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> > > > (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> > > > (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%')[/color][/color][/color]
ORDER[color=blue]
> BY[color=green][color=darkred]
> > > > OrderNo ASC
> > > >
> > > > The function ReplaceThis is working fine on this:
> > > ReplaceThis(rsResults__T)
> > > > But not on this: ReplaceThis("GenKTitles.Title")
> > > > I'm getting results that match *aint* but not *ain't*
> > > > What am I missing?
> > > > thanks for the function!!!
> > > >
> > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...
> > > > > Writing a function is fairly simple......
> > > > >
> > > > > Function ReplaceThis(sWhat)
> > > > > '// Though not necessary, I tend to lcase
> > > > > '// the string before doing anything with it
> > > > > '// as it makes it easier to work with when
> > > > > '// you want to replace the text, regardless
> > > > > '// of whether it has upper or lowercase text
> > > > >
> > > > > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > > > > End Function
> > > > >
> > > > > Then in your page, you'd simply use;
> > > > >
> > > > > Response.Write ReplaceThis("The dog went over the hill")
> > > > >
> > > > > --
> > > > >
> > > > > Regards
> > > > >
> > > > > Steven Burn
> > > > > Ur I.T. Mate Group
> > > > > www.it-mate.co.uk
> > > > >
> > > > > Keeping it FREE!
> > > > >
> > > > >
> > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...
> > > > > > Thanks to all, but if I can't get past a few syntax issues, I'll[/color]
> > never[color=darkred]
> > > > get
> > > > > > past creating a function.
> > > > > >
> > > > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > > > > I'm certainly no expert but IMHO.......
> > > > > > >
> > > > > > > Suggestion #1. Use a regular expression to do the replacing[/color][/color][/color]
for[color=blue][color=green]
> > you[color=darkred]
> > > > > > >
> > > > > > > This makes for much cleaner, and easier to read code. If you'd
> > > rather
> > > > > not
> > > > > > > use a RegExp for whatever reason, stick to a max of 2[/color][/color]
> "Replace's"[color=green][color=darkred]
> > > per
> > > > > > > line....
> > > > > > >
> > > > > > > Suggestion #2. Use a function that contains suggestion #1
> > > > > > >
> > > > > > > By using a function to do the replacing, it allows you to[/color][/color][/color]
simply[color=blue][color=green][color=darkred]
> > > use;
> > > > > > >
> > > > > > > Response.Write ReplaceThis(TheString)
> > > > > > >
> > > > > > > ... instead of ...
> > > > > > >
> > > > > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > > > > >
> > > > > > > Hint:
> > > > > > >
> > > > > > > Function ReplaceThis(sWhat)
> > > > > > > '// RegExp or whatever, code goes here.....
> > > > > > > End Function
> > > > > > >
> > > > > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc,[/color][/color]
> to[color=green][color=darkred]
> > > > write
> > > > > > the
> > > > > > > code for you....
> > > > > > >
> > > > > > > As has been mentioned by Bob, they screw up virtually[/color]
> > everything....[color=darkred]
> > > > tis
> > > > > > > much easier (and quicker) to learn how to hand code it[/color][/color][/color]
yourself[color=blue][color=green][color=darkred]
> > > (hint:
> > > > > > > aspfaq.com ;o)) using Notepad or some other text editor (just[/color][/color]
> make[color=green][color=darkred]
> > > > sure
> > > > > > you
> > > > > > > stay away from editors such as MS Word etc, if going this[/color][/color][/color]
route[color=blue]
> as[color=green][color=darkred]
> > > > > they're
> > > > > > a
> > > > > > > royal pain in the backside....).
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Regards
> > > > > > >
> > > > > > > Steven Burn
> > > > > > > Ur I.T. Mate Group
> > > > > > > www.it-mate.co.uk
> > > > > > >
> > > > > > > Keeping it FREE!
> > > > > > >
> > > > > > >
> > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > > > > It was and it wasn't related to the other post. There were 2
> > > issues
> > > > > and
> > > > > > if
> > > > > > > I
> > > > > > > > could have gotten through either, I probably could have[/color][/color][/color]
gotten[color=blue][color=green][color=darkred]
> > > > through
> > > > > > > both.
> > > > > > > > The reason I don't post everything is it looks like a huge[/color][/color]
> mess[color=green]
> > of[color=darkred]
> > > > > code
> > > > > > > > coming through the newsgroup. And I just figured it would[/color][/color][/color]
make[color=blue][color=green][color=darkred]
> > > > things
> > > > > > more
> > > > > > > > confusing. Here is the entire recordset created in[/color][/color]
> dreamweaver.[color=green]
> > It[color=darkred]
> > > > > works
> > > > > > > > fine as it is here. I know you code heads may not like[/color]
> > dreamweaver[color=darkred]
> > > > but
> > > > > > > it's
> > > > > > > > a huge crutch for those of us that don't have the knowledge[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > hand
> > > > > code
> > > > > > > > things. It works very well for what I want to do, up until I[/color]
> > want[color=darkred]
> > > to
> > > > > > give
> > > > > > > an
> > > > > > > > extra effort to make things better. For this project I have[/color][/color][/color]
to[color=blue][color=green]
> > use[color=darkred]
> > > > > > Access
> > > > > > > > 2002. I don't like it, but that's not my choice. I have a[/color][/color]
> music[color=green][color=darkred]
> > > > > database
> > > > > > > > that users can search. I get titles and artists from many[/color][/color][/color]
many[color=blue][color=green][color=darkred]
> > > > > sources.
> > > > > > > They
> > > > > > > > all choose to spell titles and artists their own way. That's[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > > > problem.
> > > > > > In
> > > > > > > > an effort to make it easier on the end users, I want to[/color][/color][/color]
remove[color=blue][color=green][color=darkred]
> > > > common
> > > > > > > words
> > > > > > > > and punctuation that varies. That includes "'", """, ",",[/color][/color][/color]
"/",[color=blue]
> "[color=green][color=darkred]
> > > ",
> > > > > "&",
> > > > > > > > "the", and "and". If I remove those characters from both[/color][/color]
> terms,[color=green]
> > it[color=darkred]
> > > > > > creates
> > > > > > > a
> > > > > > > > much better chance of relevant search results. I've done[/color][/color][/color]
this[color=blue][color=green]
> > with[color=darkred]
> > > > SQL
> > > > > > > > stored procedures and it works great. Now I have to do this[/color][/color]
> with[color=green][color=darkred]
> > > SQL
> > > > > in
> > > > > > > ASP
> > > > > > > > and I'm having a lot of syntax problems. I appreciate[/color][/color]
> everyone's[color=green][color=darkred]
> > > > > help!!!
> > > > > > I
> > > > > > > > thought I was trying to make it easier on everyone and I[/color][/color][/color]
guess[color=blue]
> I[color=green][color=darkred]
> > > > made
> > > > > it
> > > > > > > > more confusing. Sorry!
> > > > > > > >
> > > > > > > > I only have to remove those characters from titles and[/color][/color][/color]
artists[color=blue][color=green][color=darkred]
> > > > fields.
> > > > > > The
> > > > > > > > other fields I have control over the data. OK... now how do[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > > > accomplish
> > > > > > > > this feat?
> > > > > > > > thanks!
> > > > > > > >
> > > > > > > > <%
> > > > > > > > Dim rsResults__T
> > > > > > > > rsResults__T = "%"
> > > > > > > > If (Request("title") <> "") Then
> > > > > > > > rsResults__T = Request("title")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__A
> > > > > > > > rsResults__A = "%"
> > > > > > > > If (Request("artist") <> "") Then
> > > > > > > > rsResults__A = Request("artist")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__C
> > > > > > > > rsResults__C = "%"
> > > > > > > > If (Request("category") <> "") Then
> > > > > > > > rsResults__C = Request("category")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__TY
> > > > > > > > rsResults__TY = "%"
> > > > > > > > If (Request("type") <> "") Then
> > > > > > > > rsResults__TY = Request("type")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__M
> > > > > > > > rsResults__M = "%"
> > > > > > > > If (Request("manuf") <> "") Then
> > > > > > > > rsResults__M = Request("manuf")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__SA
> > > > > > > > rsResults__SA = "%"
> > > > > > > > If (Request("singleartist") <> "") Then
> > > > > > > > rsResults__SA = Request("singleartist")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults
> > > > > > > > Dim rsResults_numRows
> > > > > > > >
> > > > > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > > > > rsResults.Source = "SELECT GenKStock.OrderNo,
> > > > GenKStock.SingleArtist,
> > > > > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > > > > GenKStock.Label,
> > > > > > > > GenKStock.Description, GenKStock.Manuf,[/color][/color][/color]
GenKTitles.ItemNumber,[color=blue][color=green][color=darkred]
> > > > > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files[/color][/color][/color]
FROM[color=blue][color=green][color=darkred]
> > > > > GenKStock
> > > > > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo =[/color]
> > GenKTitles.ItemNumber[color=darkred]
> > > > > > WHERE
> > > > > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'",[/color]
> > "''")[color=darkred]
> > > +
> > > > > "'
> > > > > > +
> > > > > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +
> > > Replace(rsResults__A,
> > > > > "'",
> > > > > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > > > > Replace(rsResults__C, "'", "''") + "') AND[/color][/color][/color]
(GenKStock.Manuf[color=blue][color=green]
> > LIKE[color=darkred]
> > > > '"
> > > > > +
> > > > > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type[/color][/color]
> LIKE[color=green][color=darkred]
> > > '"
> > > > +
> > > > > > > > Replace(rsResults__TY, "'", "''") + "') AND
> > > > (GenKStock.SingleArtist
> > > > > > LIKE
> > > > > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > > > > rsResults.CursorType = 0
> > > > > > > > rsResults.CursorLocation = 2
> > > > > > > > rsResults.LockType = 1
> > > > > > > > rsResults.Open()
> > > > > > > >
> > > > > > > > rsResults_numRows = 0
> > > > > > > > %>
> > > > > > > >
> > > > > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > > 1) I'm getting this error: Syntax error (missing[/color][/color][/color]
operator)[color=blue][color=green]
> > in[color=darkred]
> > > > > query
> > > > > > > > > > expression on the below statement. Can I get some[/color][/color][/color]
advice.[color=blue][color=green][color=darkred]
> > > > > > > > > >
> > > > > > > > > > 2) I searched ASPFAQ and came up blank. Where can find[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > "rules"
> > > > > > for
> > > > > > > > > when
> > > > > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > > > > >
> > > > > > > > > > thanks!
> > > > > > > > > > ----------------------
> > > > > > > > > > SQL = SQL & "WHERE '" &
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color][/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitle[color=blue]
> s.[color=green][color=darkred]
> > > > > > > > > > Title","'",""),",",""),".",""),"
> > > > > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > > > > &
> > > > > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > This appears to be related to your other "syntax error"[/color][/color]
> post.[color=green]
> > If[color=darkred]
> > > > so,
> > > > > > it
> > > > > > > > may
> > > > > > > > > have been better to post a follow-up to that thread. Given[/color]
> > that[color=darkred]
> > > > > > context,
> > > > > > > > it
> > > > > > > > > appears that you're attempting to eliminate false[/color][/color][/color]
positives[color=blue][color=green]
> > from[color=darkred]
> > > > > your
> > > > > > > > > searches by discluding common words and punctuations. If[/color][/color]
> this[color=green]
> > is[color=darkred]
> > > > the
> > > > > > > case,
> > > > > > > > > perhaps it would be easier to remove those items from the[/color]
> > search[color=darkred]
> > > > > term
> > > > > > > > > instead of attempting to remove them from the[/color][/color]
> GenKTitles.Title[color=green][color=darkred]
> > > > > column
> > > > > > in
> > > > > > > > > your database. If you took this approach you could make[/color][/color][/color]
use[color=blue]
> of[color=green]
> > a[color=darkred]
> > > > > > regular
> > > > > > > > > expression to "scrub" the search term prior to[/color][/color][/color]
constructing[color=blue][color=green]
> > the[color=darkred]
> > > > SQL
> > > > > > > > > statement. Also, please consider using a stored procedure[/color][/color]
> (or[color=green][color=darkred]
> > > > > > > > parameterized
> > > > > > > > > query depending on your database environment) instead of
> > > > dynamically
> > > > > > > > > constructing the SQL statement. Also, in the future,[/color][/color][/color]
please[color=blue][color=green][color=darkred]
> > > > provide
> > > > > > > > > database, version, DDL, sample data and desired[/color]
> > output/results.[color=darkred]
> > > > > Here's
> > > > > > > are
> > > > > > > > > some guidelines
> > > > > > > > >
> > > > > > > > > http://aspfaq.com/5000
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


shank
Guest
 
Posts: n/a
#26: Jul 19 '05

re: Syntax error (missing operator) in query expression


>>But surely, if it's to be an effective search, you don't want a match on
all variations<<
Yes! Absolutely I want to match on all variations! There are too many
variations in the data plus what the user may search upon. I have to replace
those common characters in BOTH the data and criteria.

I can use the function on the IF blocks - no problem. But I still have to
replace the common characters in the data. Hence, the syntax problem.
[color=blue][color=green]
>>WTF is this all about? AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND<<[/color][/color]
These are more fields that can be searched upon to narrow the search
results. Dreamweaver generates the code using the SQL wildcard % and of
course the + signs. Like it or not, it all works well, except for this
Replacing of the common characters.

thanks

"Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
news:Om$iomafEHA.3536@TK2MSFTNGP12.phx.gbl...[color=blue]
> What Steve means is - Why aren't you using it in your IF blocks...
> <%
> Dim rsResults__A
> rsResults__A = "%"
> If (Request("artist") <> "") Then
> rsResults__A = ReplaceThis(Request("artist"))
> End If
> %>
>
> Then just use rsResults__A when you build your string fir the SQL, which
> will make that code much more readable.
>
> Does GENKTITLES.TITLE contain a " ' "? If it does, then why would you[/color]
expect[color=blue]
> a match?
>
> WTF is this all about? AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
>
> Bob Lehmann
>
>
> "shank" <shank@tampabay.rr.com> wrote in message
> news:eiHcbZafEHA.712@TK2MSFTNGP09.phx.gbl...[color=green]
> > Example: In the data, some variations of the word ain't include: ain't,
> > aint, aint'
> > I have no control over what the user searches on, so I have to remove[/color][/color]
the[color=blue][color=green]
> > apostrophe from what they submit and also the apostrophe that's in the[/color]
> data.[color=green]
> > Otherwise I would not get a hit on all 3 variations.
> >
> > "Steven Burn" <pvt@noyb.com> wrote in message
> > news:%234EZJHafEHA.2848@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Why are you trying to use the function in the SQL query string?
> > >
> > > --
> > >
> > > Regards
> > >
> > > Steven Burn
> > > Ur I.T. Mate Group
> > > www.it-mate.co.uk
> > >
> > > Keeping it FREE!
> > >
> > >
> > > "shank" <shank@tampabay.rr.com> wrote in message
> > > news:eiyt14ZfEHA.2352@TK2MSFTNGP09.phx.gbl...
> > > > I really like the idea of the function, but having problems with[/color][/color]
> syntax[color=green][color=darkred]
> > > > again. I'm starting simple by removing the apostrophes.
> > > >
> > > > <%
> > > > Function ReplaceThis(sWhat)
> > > > ReplaceThis = Replace(UCase(sWhat), "'", "")
> > > > End Function
> > > > %>
> > > >
> > > > I'm just including the portion o fthe WHERE clause where I'm
> > > experimenting.
> > > >
> > > > WHERE ( " & ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > > > ReplaceThis(rsResults__T) + "' + '%')
> > > >
> > > > The SQL to my page is....
> > > > SQL = SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> > > GenKStock.SoftHard,
> > > > GenKStock.Category, GenKStock.Type, GenKStock.Label,
> > > GenKStock.Description,
> > > > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,
> > > GenKTitles.Artist,
> > > > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > > > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( GENKTITLES.TITLE[/color][/color]
> LIKE[color=green][color=darkred]
> > > '%'
> > > > + 'AINT' + '%') AND (GenKTitles.Artist LIKE '%' + '%' + '%') AND
> > > > (GenKStock.Category LIKE '%') AND (GenKStock.Manuf LIKE '%') AND
> > > > (GenKStock.Type LIKE '%') AND (GenKStock.SingleArtist LIKE '%')[/color][/color][/color]
ORDER[color=blue]
> BY[color=green][color=darkred]
> > > > OrderNo ASC
> > > >
> > > > The function ReplaceThis is working fine on this:
> > > ReplaceThis(rsResults__T)
> > > > But not on this: ReplaceThis("GenKTitles.Title")
> > > > I'm getting results that match *aint* but not *ain't*
> > > > What am I missing?
> > > > thanks for the function!!!
> > > >
> > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > news:uAffTlZfEHA.708@TK2MSFTNGP09.phx.gbl...
> > > > > Writing a function is fairly simple......
> > > > >
> > > > > Function ReplaceThis(sWhat)
> > > > > '// Though not necessary, I tend to lcase
> > > > > '// the string before doing anything with it
> > > > > '// as it makes it easier to work with when
> > > > > '// you want to replace the text, regardless
> > > > > '// of whether it has upper or lowercase text
> > > > >
> > > > > ReplaceThis = Replace(lcase(sWhat), "the dog", "some text")
> > > > > End Function
> > > > >
> > > > > Then in your page, you'd simply use;
> > > > >
> > > > > Response.Write ReplaceThis("The dog went over the hill")
> > > > >
> > > > > --
> > > > >
> > > > > Regards
> > > > >
> > > > > Steven Burn
> > > > > Ur I.T. Mate Group
> > > > > www.it-mate.co.uk
> > > > >
> > > > > Keeping it FREE!
> > > > >
> > > > >
> > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > news:uPET0eZfEHA.644@tk2msftngp13.phx.gbl...
> > > > > > Thanks to all, but if I can't get past a few syntax issues, I'll[/color]
> > never[color=darkred]
> > > > get
> > > > > > past creating a function.
> > > > > >
> > > > > > "Steven Burn" <pvt@noyb.com> wrote in message
> > > > > > news:O7iKTUZfEHA.384@TK2MSFTNGP10.phx.gbl...
> > > > > > > I'm certainly no expert but IMHO.......
> > > > > > >
> > > > > > > Suggestion #1. Use a regular expression to do the replacing[/color][/color][/color]
for[color=blue][color=green]
> > you[color=darkred]
> > > > > > >
> > > > > > > This makes for much cleaner, and easier to read code. If you'd
> > > rather
> > > > > not
> > > > > > > use a RegExp for whatever reason, stick to a max of 2[/color][/color]
> "Replace's"[color=green][color=darkred]
> > > per
> > > > > > > line....
> > > > > > >
> > > > > > > Suggestion #2. Use a function that contains suggestion #1
> > > > > > >
> > > > > > > By using a function to do the replacing, it allows you to[/color][/color][/color]
simply[color=blue][color=green][color=darkred]
> > > use;
> > > > > > >
> > > > > > > Response.Write ReplaceThis(TheString)
> > > > > > >
> > > > > > > ... instead of ...
> > > > > > >
> > > > > > > Response.Write Replace(Replace(Replace.... etc etc etc
> > > > > > >
> > > > > > > Hint:
> > > > > > >
> > > > > > > Function ReplaceThis(sWhat)
> > > > > > > '// RegExp or whatever, code goes here.....
> > > > > > > End Function
> > > > > > >
> > > > > > > Suggestion #3. NEVER use wysywig app's such as DW, FP etc etc,[/color][/color]
> to[color=green][color=darkred]
> > > > write
> > > > > > the
> > > > > > > code for you....
> > > > > > >
> > > > > > > As has been mentioned by Bob, they screw up virtually[/color]
> > everything....[color=darkred]
> > > > tis
> > > > > > > much easier (and quicker) to learn how to hand code it[/color][/color][/color]
yourself[color=blue][color=green][color=darkred]
> > > (hint:
> > > > > > > aspfaq.com ;o)) using Notepad or some other text editor (just[/color][/color]
> make[color=green][color=darkred]
> > > > sure
> > > > > > you
> > > > > > > stay away from editors such as MS Word etc, if going this[/color][/color][/color]
route[color=blue]
> as[color=green][color=darkred]
> > > > > they're
> > > > > > a
> > > > > > > royal pain in the backside....).
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Regards
> > > > > > >
> > > > > > > Steven Burn
> > > > > > > Ur I.T. Mate Group
> > > > > > > www.it-mate.co.uk
> > > > > > >
> > > > > > > Keeping it FREE!
> > > > > > >
> > > > > > >
> > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > news:ODkPZIYfEHA.3536@TK2MSFTNGP12.phx.gbl...
> > > > > > > > It was and it wasn't related to the other post. There were 2
> > > issues
> > > > > and
> > > > > > if
> > > > > > > I
> > > > > > > > could have gotten through either, I probably could have[/color][/color][/color]
gotten[color=blue][color=green][color=darkred]
> > > > through
> > > > > > > both.
> > > > > > > > The reason I don't post everything is it looks like a huge[/color][/color]
> mess[color=green]
> > of[color=darkred]
> > > > > code
> > > > > > > > coming through the newsgroup. And I just figured it would[/color][/color][/color]
make[color=blue][color=green][color=darkred]
> > > > things
> > > > > > more
> > > > > > > > confusing. Here is the entire recordset created in[/color][/color]
> dreamweaver.[color=green]
> > It[color=darkred]
> > > > > works
> > > > > > > > fine as it is here. I know you code heads may not like[/color]
> > dreamweaver[color=darkred]
> > > > but
> > > > > > > it's
> > > > > > > > a huge crutch for those of us that don't have the knowledge[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > hand
> > > > > code
> > > > > > > > things. It works very well for what I want to do, up until I[/color]
> > want[color=darkred]
> > > to
> > > > > > give
> > > > > > > an
> > > > > > > > extra effort to make things better. For this project I have[/color][/color][/color]
to[color=blue][color=green]
> > use[color=darkred]
> > > > > > Access
> > > > > > > > 2002. I don't like it, but that's not my choice. I have a[/color][/color]
> music[color=green][color=darkred]
> > > > > database
> > > > > > > > that users can search. I get titles and artists from many[/color][/color][/color]
many[color=blue][color=green][color=darkred]
> > > > > sources.
> > > > > > > They
> > > > > > > > all choose to spell titles and artists their own way. That's[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > > > problem.
> > > > > > In
> > > > > > > > an effort to make it easier on the end users, I want to[/color][/color][/color]
remove[color=blue][color=green][color=darkred]
> > > > common
> > > > > > > words
> > > > > > > > and punctuation that varies. That includes "'", """, ",",[/color][/color][/color]
"/",[color=blue]
> "[color=green][color=darkred]
> > > ",
> > > > > "&",
> > > > > > > > "the", and "and". If I remove those characters from both[/color][/color]
> terms,[color=green]
> > it[color=darkred]
> > > > > > creates
> > > > > > > a
> > > > > > > > much better chance of relevant search results. I've done[/color][/color][/color]
this[color=blue][color=green]
> > with[color=darkred]
> > > > SQL
> > > > > > > > stored procedures and it works great. Now I have to do this[/color][/color]
> with[color=green][color=darkred]
> > > SQL
> > > > > in
> > > > > > > ASP
> > > > > > > > and I'm having a lot of syntax problems. I appreciate[/color][/color]
> everyone's[color=green][color=darkred]
> > > > > help!!!
> > > > > > I
> > > > > > > > thought I was trying to make it easier on everyone and I[/color][/color][/color]
guess[color=blue]
> I[color=green][color=darkred]
> > > > made
> > > > > it
> > > > > > > > more confusing. Sorry!
> > > > > > > >
> > > > > > > > I only have to remove those characters from titles and[/color][/color][/color]
artists[color=blue][color=green][color=darkred]
> > > > fields.
> > > > > > The
> > > > > > > > other fields I have control over the data. OK... now how do[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > > > accomplish
> > > > > > > > this feat?
> > > > > > > > thanks!
> > > > > > > >
> > > > > > > > <%
> > > > > > > > Dim rsResults__T
> > > > > > > > rsResults__T = "%"
> > > > > > > > If (Request("title") <> "") Then
> > > > > > > > rsResults__T = Request("title")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__A
> > > > > > > > rsResults__A = "%"
> > > > > > > > If (Request("artist") <> "") Then
> > > > > > > > rsResults__A = Request("artist")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__C
> > > > > > > > rsResults__C = "%"
> > > > > > > > If (Request("category") <> "") Then
> > > > > > > > rsResults__C = Request("category")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__TY
> > > > > > > > rsResults__TY = "%"
> > > > > > > > If (Request("type") <> "") Then
> > > > > > > > rsResults__TY = Request("type")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__M
> > > > > > > > rsResults__M = "%"
> > > > > > > > If (Request("manuf") <> "") Then
> > > > > > > > rsResults__M = Request("manuf")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults__SA
> > > > > > > > rsResults__SA = "%"
> > > > > > > > If (Request("singleartist") <> "") Then
> > > > > > > > rsResults__SA = Request("singleartist")
> > > > > > > > End If
> > > > > > > > %>
> > > > > > > > <%
> > > > > > > > Dim rsResults
> > > > > > > > Dim rsResults_numRows
> > > > > > > >
> > > > > > > > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > > > > > > > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > > > > > > > rsResults.Source = "SELECT GenKStock.OrderNo,
> > > > GenKStock.SingleArtist,
> > > > > > > > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > > > > GenKStock.Label,
> > > > > > > > GenKStock.Description, GenKStock.Manuf,[/color][/color][/color]
GenKTitles.ItemNumber,[color=blue][color=green][color=darkred]
> > > > > > > > GenKTitles.Title, GenKTitles.Artist, GenKTitles.mp3Files[/color][/color][/color]
FROM[color=blue][color=green][color=darkred]
> > > > > GenKStock
> > > > > > > > INNER JOIN GenKTitles ON GenKStock.OrderNo =[/color]
> > GenKTitles.ItemNumber[color=darkred]
> > > > > > WHERE
> > > > > > > > (GenKTitles.Title LIKE '%' + '" + Replace(rsResults__T, "'",[/color]
> > "''")[color=darkred]
> > > +
> > > > > "'
> > > > > > +
> > > > > > > > '%') AND (GenKTitles.Artist LIKE '%' + '" +
> > > Replace(rsResults__A,
> > > > > "'",
> > > > > > > > "''") + "' + '%') AND (GenKStock.Category LIKE '" +
> > > > > > > > Replace(rsResults__C, "'", "''") + "') AND[/color][/color][/color]
(GenKStock.Manuf[color=blue][color=green]
> > LIKE[color=darkred]
> > > > '"
> > > > > +
> > > > > > > > Replace(rsResults__M, "'", "''") + "') AND (GenKStock.Type[/color][/color]
> LIKE[color=green][color=darkred]
> > > '"
> > > > +
> > > > > > > > Replace(rsResults__TY, "'", "''") + "') AND
> > > > (GenKStock.SingleArtist
> > > > > > LIKE
> > > > > > > > '" + Replace(rsResults__SA, "'", "''") + "')"
> > > > > > > > rsResults.CursorType = 0
> > > > > > > > rsResults.CursorLocation = 2
> > > > > > > > rsResults.LockType = 1
> > > > > > > > rsResults.Open()
> > > > > > > >
> > > > > > > > rsResults_numRows = 0
> > > > > > > > %>
> > > > > > > >
> > > > > > > > "Chris Hohmann" <nospam@thankyou.com> wrote in message
> > > > > > > > news:%235jY4zMfEHA.3204@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > "shank" <shank@tampabay.rr.com> wrote in message
> > > > > > > > > news:egW5MiCfEHA.4092@TK2MSFTNGP10.phx.gbl...
> > > > > > > > > > 1) I'm getting this error: Syntax error (missing[/color][/color][/color]
operator)[color=blue][color=green]
> > in[color=darkred]
> > > > > query
> > > > > > > > > > expression on the below statement. Can I get some[/color][/color][/color]
advice.[color=blue][color=green][color=darkred]
> > > > > > > > > >
> > > > > > > > > > 2) I searched ASPFAQ and came up blank. Where can find[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > "rules"
> > > > > > for
> > > > > > > > > when
> > > > > > > > > > and how to use single quotes and double quotes in ASP?
> > > > > > > > > >
> > > > > > > > > > thanks!
> > > > > > > > > > ----------------------
> > > > > > > > > > SQL = SQL & "WHERE '" &
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >[/color]
> >[/color][/color]
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(RE PLACE(REPLACE("GenKTitle[color=blue]
> s.[color=green][color=darkred]
> > > > > > > > > > Title","'",""),",",""),".",""),"
> > > > > > > > ",""),"the",""),"and",""),"&",""),"/","")
> > > > > > > > > &
> > > > > > > > > > "' LIKE '%' '" & T & "' '%' "
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > This appears to be related to your other "syntax error"[/color][/color]
> post.[color=green]
> > If[color=darkred]
> > > > so,
> > > > > > it
> > > > > > > > may
> > > > > > > > > have been better to post a follow-up to that thread. Given[/color]
> > that[color=darkred]
> > > > > > context,
> > > > > > > > it
> > > > > > > > > appears that you're attempting to eliminate false[/color][/color][/color]
positives[color=blue][color=green]
> > from[color=darkred]
> > > > > your
> > > > > > > > > searches by discluding common words and punctuations. If[/color][/color]
> this[color=green]
> > is[color=darkred]
> > > > the
> > > > > > > case,
> > > > > > > > > perhaps it would be easier to remove those items from the[/color]
> > search[color=darkred]
> > > > > term
> > > > > > > > > instead of attempting to remove them from the[/color][/color]
> GenKTitles.Title[color=green][color=darkred]
> > > > > column
> > > > > > in
> > > > > > > > > your database. If you took this approach you could make[/color][/color][/color]
use[color=blue]
> of[color=green]
> > a[color=darkred]
> > > > > > regular
> > > > > > > > > expression to "scrub" the search term prior to[/color][/color][/color]
constructing[color=blue][color=green]
> > the[color=darkred]
> > > > SQL
> > > > > > > > > statement. Also, please consider using a stored procedure[/color][/color]
> (or[color=green][color=darkred]
> > > > > > > > parameterized
> > > > > > > > > query depending on your database environment) instead of
> > > > dynamically
> > > > > > > > > constructing the SQL statement. Also, in the future,[/color][/color][/color]
please[color=blue][color=green][color=darkred]
> > > > provide
> > > > > > > > > database, version, DDL, sample data and desired[/color]
> > output/results.[color=darkred]
> > > > > Here's
> > > > > > > are
> > > > > > > > > some guidelines
> > > > > > > > >
> > > > > > > > > http://aspfaq.com/5000
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Bob Barrows [MVP]
Guest
 
Posts: n/a
#27: Jul 19 '05

re: Syntax error (missing operator) in query expression


shank wrote:[color=blue]
> This is my code to build the recordset...
> <%
> Dim rsResults
> Dim rsResults_numRows
>
> Set rsResults = Server.CreateObject("ADODB.Recordset")
> rsResults.ActiveConnection = MM_GenKAccess_STRING
> rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> GenKStock.Label, GenKStock.Description, GenKStock.Manuf,
> GenKTitles.ItemNumber, GenKTitles.Title, GenKTitles.Artist,
> GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( " &
> ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> ReplaceThis(rsResults__T) + "' + '%') AND (GenKTitles.Artist LIKE
> '%' + '" + Replace(rsResults__A, "'", "''") + "' + '%') AND
> (GenKStock.Category LIKE '" + Replace(rsResults__C, "'", "''") + "')
> AND (GenKStock.Manuf LIKE '" + Replace(rsResults__M, "'", "''") + "')
> AND (GenKStock.Type LIKE '" + Replace(rsResults__TY, "'", "''") + "')
> AND (GenKStock.SingleArtist LIKE '" + Replace(rsResults__SA, "'",
> "''") + "') ORDER BY " + Replace(rsResults__sql_orderby, "'", "''")
> + ""
> rsResults.CursorType = 0
> rsResults.CursorLocation = 2
> rsResults.LockType = 1
> rsResults.Open()
>
> rsResults_numRows = 0
> %>
>
> Then, down in the HTML I have this code: SQL = <%=rsResults.Source%>
>
> Which gives me this: SQL = SELECT GenKStock.OrderNo,
> GenKStock.SingleArtist, GenKStock.SoftHard, GenKStock.Category,
> GenKStock.Type, GenKStock.Label, GenKStock.Description,
> GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,
> GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock INNER JOIN
> GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE (
> GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND (GenKTitles.Artist LIKE
> '%' + '%' + '%') AND (GenKStock.Category LIKE '%') AND
> (GenKStock.Manuf LIKE '%') AND (GenKStock.Type LIKE '%') AND
> (GenKStock.SingleArtist LIKE '%') ORDER BY OrderNo ASC
>
> Response.write SQL gives me nothing because there is no variable
> named SQL. This is response.write SQL: <%=Response.Write(SQL)%>
> (gives me no results) Sorry if I don't understand what you want.[/color]

Well then you need to create a variable called SQL. (I usually call it sSQL,
but you can do what you want: it's your code) It is good programming
practice to assign the result of string concatenations to a variable so you
can inspect the variable (using Response.Write in server-side code). You can
use the variable in your recordset's Source statment instead of the string
concatenation code:

rsResults.Source = sSQL


However, having said that, I now see that you've response.written the
recordset's Source property, you has given us what I asked for. My mistake.

The other thing you've never told us is what database you are using. If you
are using Access, this

GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND

should be this:

GENKTITLES.TITLE LIKE '%' & 'AINT' & '%') AND

I am going to refrain from further analysis until I find out what database
you are using.

I will say that you seem to have an inordinate number of comparisons to '%'.
Do you have any idea what this sql statement should really look like? Have
you used your database's query tool to test the query to make sure it gives
you what you want? This is another good programming practice. You can't run
a query unless you know what the query is supposed to look like.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


shank
Guest
 
Posts: n/a
#28: Jul 19 '05

re: Syntax error (missing operator) in query expression


I'm using Access 2002. I mentioned that somewhere, but not sure where now.
Yes I ran the query in Access and viewed the query in SQL mode. The query
works fine. The problem comes into play when I try using the Replace on both
sides of the coin: data and criteria. The replace for criteria works well. I
just can't get the syntax for the data side correct.
thanks!

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23oXR45afEHA.712@TK2MSFTNGP09.phx.gbl...[color=blue]
> shank wrote:[color=green]
> > This is my code to build the recordset...
> > <%
> > Dim rsResults
> > Dim rsResults_numRows
> >
> > Set rsResults = Server.CreateObject("ADODB.Recordset")
> > rsResults.ActiveConnection = MM_GenKAccess_STRING
> > rsResults.Source = "SELECT GenKStock.OrderNo, GenKStock.SingleArtist,
> > GenKStock.SoftHard, GenKStock.Category, GenKStock.Type,
> > GenKStock.Label, GenKStock.Description, GenKStock.Manuf,
> > GenKTitles.ItemNumber, GenKTitles.Title, GenKTitles.Artist,
> > GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
> > GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( " &
> > ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
> > ReplaceThis(rsResults__T) + "' + '%') AND (GenKTitles.Artist LIKE
> > '%' + '" + Replace(rsResults__A, "'", "''") + "' + '%') AND
> > (GenKStock.Category LIKE '" + Replace(rsResults__C, "'", "''") + "')
> > AND (GenKStock.Manuf LIKE '" + Replace(rsResults__M, "'", "''") + "')
> > AND (GenKStock.Type LIKE '" + Replace(rsResults__TY, "'", "''") + "')
> > AND (GenKStock.SingleArtist LIKE '" + Replace(rsResults__SA, "'",
> > "''") + "') ORDER BY " + Replace(rsResults__sql_orderby, "'", "''")
> > + ""
> > rsResults.CursorType = 0
> > rsResults.CursorLocation = 2
> > rsResults.LockType = 1
> > rsResults.Open()
> >
> > rsResults_numRows = 0
> > %>
> >
> > Then, down in the HTML I have this code: SQL = <%=rsResults.Source%>
> >
> > Which gives me this: SQL = SELECT GenKStock.OrderNo,
> > GenKStock.SingleArtist, GenKStock.SoftHard, GenKStock.Category,
> > GenKStock.Type, GenKStock.Label, GenKStock.Description,
> > GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,
> > GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock INNER JOIN
> > GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE (
> > GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND (GenKTitles.Artist LIKE
> > '%' + '%' + '%') AND (GenKStock.Category LIKE '%') AND
> > (GenKStock.Manuf LIKE '%') AND (GenKStock.Type LIKE '%') AND
> > (GenKStock.SingleArtist LIKE '%') ORDER BY OrderNo ASC
> >
> > Response.write SQL gives me nothing because there is no variable
> > named SQL. This is response.write SQL: <%=Response.Write(SQL)%>
> > (gives me no results) Sorry if I don't understand what you want.[/color]
>
> Well then you need to create a variable called SQL. (I usually call it[/color]
sSQL,[color=blue]
> but you can do what you want: it's your code) It is good programming
> practice to assign the result of string concatenations to a variable so[/color]
you[color=blue]
> can inspect the variable (using Response.Write in server-side code). You[/color]
can[color=blue]
> use the variable in your recordset's Source statment instead of the string
> concatenation code:
>
> rsResults.Source = sSQL
>
>
> However, having said that, I now see that you've response.written the
> recordset's Source property, you has given us what I asked for. My[/color]
mistake.[color=blue]
>
> The other thing you've never told us is what database you are using. If[/color]
you[color=blue]
> are using Access, this
>
> GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND
>
> should be this:
>
> GENKTITLES.TITLE LIKE '%' & 'AINT' & '%') AND
>
> I am going to refrain from further analysis until I find out what database
> you are using.
>
> I will say that you seem to have an inordinate number of comparisons to[/color]
'%'.[color=blue]
> Do you have any idea what this sql statement should really look like? Have
> you used your database's query tool to test the query to make sure it[/color]
gives[color=blue]
> you what you want? This is another good programming practice. You can't[/color]
run[color=blue]
> a query unless you know what the query is supposed to look like.
>
> Bob Barrows
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>[/color]


Aaron [SQL Server MVP]
Guest
 
Posts: n/a
#29: Jul 19 '05

re: Syntax error (missing operator) in query expression


> Thanks to all, but if I can't get past a few syntax issues, I'll never get[color=blue]
> past creating a function.[/color]

You'll never even get TO creating a function if you insist on using crapware
like DreamWeaver to do your work for you.

Sorry to be blunt, but it's your own reliance on these tools that is causing
the "few syntax issues" in the first place.


Bob Barrows [MVP]
Guest
 
Posts: n/a
#30: Jul 19 '05

re: Syntax error (missing operator) in query expression


What you need to do is use the query tool in Access to create the query with
the Replace function on the data, so you can see what it's supposed to look
like when it works (PS. It is a really bad idea to do this. Your query will
not perform very well if you use pass columns to functions in your WHERE
clause. Also, you cannot use user-defined function in your queries when you
call them via ADO. You must use only built-in VBA functions. So that
ReplaceThis function will not work when you call the query from ASP).

Your task will be made much simpler if, when you get a query that works in
the query tool (you have to use * instead of % in the WHERE clause when you
run the query using the query tool - change the * back to % when you run it
via ADO), you parameterize and save the query, which can more easily be run
from ASP than all this concatenation business. Do a quick Google for posts
by me containing the words "saved parameter query" to see how easy this can
be. You will no longer have to worry about all the stupid "quote" issues.

Bob Barrows

shank wrote:[color=blue]
> I'm using Access 2002. I mentioned that somewhere, but not sure where
> now. Yes I ran the query in Access and viewed the query in SQL mode.
> The query works fine. The problem comes into play when I try using
> the Replace on both sides of the coin: data and criteria. The replace
> for criteria works well. I just can't get the syntax for the data
> side correct.
> thanks!
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:%23oXR45afEHA.712@TK2MSFTNGP09.phx.gbl...[color=green]
>> shank wrote:[color=darkred]
>>> This is my code to build the recordset...
>>> <%
>>> Dim rsResults
>>> Dim rsResults_numRows
>>>
>>> Set rsResults = Server.CreateObject("ADODB.Recordset")
>>> rsResults.ActiveConnection = MM_GenKAccess_STRING
>>> rsResults.Source = "SELECT GenKStock.OrderNo,
>>> GenKStock.SingleArtist, GenKStock.SoftHard, GenKStock.Category,
>>> GenKStock.Type,
>>> GenKStock.Label, GenKStock.Description, GenKStock.Manuf,
>>> GenKTitles.ItemNumber, GenKTitles.Title, GenKTitles.Artist,
>>> GenKTitles.mp3Files FROM GenKStock INNER JOIN GenKTitles ON
>>> GenKStock.OrderNo = GenKTitles.ItemNumber WHERE ( " &
>>> ReplaceThis("GenKTitles.Title") & " LIKE '%' + '" +
>>> ReplaceThis(rsResults__T) + "' + '%') AND (GenKTitles.Artist LIKE
>>> '%' + '" + Replace(rsResults__A, "'", "''") + "' + '%') AND
>>> (GenKStock.Category LIKE '" + Replace(rsResults__C, "'", "''") + "')
>>> AND (GenKStock.Manuf LIKE '" + Replace(rsResults__M, "'", "''") +
>>> "') AND (GenKStock.Type LIKE '" + Replace(rsResults__TY, "'", "''")
>>> + "') AND (GenKStock.SingleArtist LIKE '" + Replace(rsResults__SA,
>>> "'", "''") + "') ORDER BY " + Replace(rsResults__sql_orderby, "'",
>>> "''") + ""
>>> rsResults.CursorType = 0
>>> rsResults.CursorLocation = 2
>>> rsResults.LockType = 1
>>> rsResults.Open()
>>>
>>> rsResults_numRows = 0
>>> %>
>>>
>>> Then, down in the HTML I have this code: SQL = <%=rsResults.Source%>
>>>
>>> Which gives me this: SQL = SELECT GenKStock.OrderNo,
>>> GenKStock.SingleArtist, GenKStock.SoftHard, GenKStock.Category,
>>> GenKStock.Type, GenKStock.Label, GenKStock.Description,
>>> GenKStock.Manuf, GenKTitles.ItemNumber, GenKTitles.Title,
>>> GenKTitles.Artist, GenKTitles.mp3Files FROM GenKStock INNER JOIN
>>> GenKTitles ON GenKStock.OrderNo = GenKTitles.ItemNumber WHERE (
>>> GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND (GenKTitles.Artist
>>> LIKE '%' + '%' + '%') AND (GenKStock.Category LIKE '%') AND
>>> (GenKStock.Manuf LIKE '%') AND (GenKStock.Type LIKE '%') AND
>>> (GenKStock.SingleArtist LIKE '%') ORDER BY OrderNo ASC
>>>
>>> Response.write SQL gives me nothing because there is no variable
>>> named SQL. This is response.write SQL: <%=Response.Write(SQL)%>
>>> (gives me no results) Sorry if I don't understand what you want.[/color]
>>
>> Well then you need to create a variable called SQL. (I usually call
>> it sSQL, but you can do what you want: it's your code) It is good
>> programming practice to assign the result of string concatenations
>> to a variable so you can inspect the variable (using Response.Write
>> in server-side code). You can use the variable in your recordset's
>> Source statment instead of the string concatenation code:
>>
>> rsResults.Source = sSQL
>>
>>
>> However, having said that, I now see that you've response.written the
>> recordset's Source property, you has given us what I asked for. My
>> mistake.
>>
>> The other thing you've never told us is what database you are using.
>> If you are using Access, this
>>
>> GENKTITLES.TITLE LIKE '%' + 'AINT' + '%') AND
>>
>> should be this:
>>
>> GENKTITLES.TITLE LIKE '%' & 'AINT' & '%') AND
>>
>> I am going to refrain from further analysis until I find out what
>> database you are using.
>>
>> I will say that you seem to have an inordinate number of comparisons
>> to '%'. Do you have any idea what this sql statement should really
>> look like? Have you used your database's query tool to test the
>> query to make sure it gives you what you want? This is another good
>> programming practice. You can't run a query unless you know what the
>> query is supposed to look like.
>>
>> Bob Barrows
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so
>> I don't check it very often. If you must reply off-line, then remove
>> the "NO SPAM"[/color][/color]

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Closed Thread