Forums

This topic is locked

Query Quotes Help Needed, please

Posted 15 Sep 2002 07:49:26
1
has voted
15 Sep 2002 07:49:26 Matthew Dehait posted:
Here's the query now:

SELECT * FROM DBO.FILELIBRARY WHERE (CONTAINS(fileTitle, ' FORMSOF
(INFLECTIONAL, " & Request.QueryString("searchterm" & " ') OR CONTAINS(fileDescription, ' FORMSOF (INFLECTIONAL, " &
Request.QueryString("searchterm" & " ') OR CONTAINS(fileKeywords, ' FORMSOF (INFLECTIONAL, " & Request.QueryString("searchterm" & " ')) and fileAccessLevels LIKE '%admin%' ORDER BY fileDate DESC"

Which works great as long as you only type one work into the search, otherwise, you get this:

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error occurred near 'sd'. Expected '',', ')'' in search condition ' FORMSOF (INFLECTIONAL, provider sd) '.

The space is messing it up. I need for that querystring to appear in quotes. If you type the search in quotes on the form, it works fine. I don't know how to write that query so it adds the quotes right.

Thoughts? Thanks.

Matthew Dehait

Replies

Replied 16 Sep 2002 11:08:44
16 Sep 2002 11:08:44 Viktor Farcic replied:
You'll need to replace single with double quote within a string on a page. If you're using ASP/VBScript it would be something like:<pre id=code><font face=courier size=2 id=code>&lt;% SomeString = Replace(SomeString, "'", "''" %&gt;</font id=code></pre id=code>. After replacement you're free to use that string (i.e. SomeString) within your query.

Viktor Farcic
www.farcic.com
TalkZone Manager

Reply to this topic