I have a search function created that will allow people to look for titles but two issues I am coming accross is that if you place a ' in the query it sees it as end of the quary item for that field and will error out. The other is if you put in an extra space at the end it will not locate the search. I know I could use two strings and take care of it but that would be several lines of coding and wanted to see if anyone knew of a quicker way to check for these and make is so that the ' is recognized as part of the title and that the extra space at the end is not part of the search. Also the ability to check that no other punctuation will cause it to error out.
Here is my current code for that section:
if request("type") = "1" then
rsArticle.Open ("SELECT * FROM article WHERE Title LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Title LIKE '%") & "%'" & " OR Summary LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Summary LIKE '%") & "%' OR Author LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Author LIKE '%") & "' ORDER BY IssueNo DESC"), cnArticle,1,1
response.write "<p align='left'><font face='verdana, arial' size='1'> Search result(s) for "<b>" & sSearch & "</b>" " & rsArticle.RecordCount & " articles total</font></p>
Here is my current code for that section:
if request("type") = "1" then
rsArticle.Open ("SELECT * FROM article WHERE Title LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Title LIKE '%") & "%'" & " OR Summary LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Summary LIKE '%") & "%' OR Author LIKE '%" & Replace( Trim( sSearch ), " ", "%' AND Author LIKE '%") & "' ORDER BY IssueNo DESC"), cnArticle,1,1
response.write "<p align='left'><font face='verdana, arial' size='1'> Search result(s) for "<b>" & sSearch & "</b>" " & rsArticle.RecordCount & " articles total</font></p>