Re: Syntax error (missing operator) in query expression

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris Hohmann (nospam_at_thankyou.com)
Date: 08/07/04


Date: Sat, 7 Aug 2004 15:32:38 -0700


"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" for
when
> and how to use single quotes and double quotes in ASP?
>
> thanks!
> ----------------------
> SQL = SQL & "WHERE '" &
>
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE("GenKTitles.
> Title","'",""),",",""),".","")," ",""),"the",""),"and",""),"&",""),"/","")
&
> "' LIKE '%' '" & T & "' '%' "
>

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



Relevant Pages

  • Re: Repace function in a query
    ... Can you post the SQL statement for the query? ... Are you certain there are no References marked as MISSING in your database? ... > wanted to replace them with single quotes. ...
    (microsoft.public.access.queries)
  • Possible "bug" found in gnatcoll-sql_impl.adb
    ... I end up with more characters than I've bargained for. ... I end up with Peter in the database. ... extra single quotes added to all my string data. ...
    (comp.lang.ada)
  • Re: Escape html tags and other dangerous input
    ... The & affects the querystring. ... Single quotes can end the SQL statement allowing for a SQL ... >> injection, but that doesn't help with the ampersand, and the search page ...
    (microsoft.public.dotnet.security)
  • Re: SQL Injection
    ... Make sure you always escape single quotes and other magic characters when ... you enter data into your database. ...
    (borland.public.delphi.non-technical)
  • Re: Handling single quotes " " in data
    ... There's no reason not to store the single quotes. ... Presumably your SQL statement is something like ... (remove the extra spaces in the parameters in the Replace statement before ... > I have been storing file locations in a table in access. ...
    (microsoft.public.access.modulesdaovba)