Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

apostrophe in asp search

Posted on 1999-06-29
7
Medium Priority
?
168 Views
Last Modified: 2013-12-25
When I use an apostrophe as part of a serch term - eg:
"men's thoughts"
I get a syntax error returned.
What is the workaround without replacing these in the database and then replacing them back in the search results?
Cheers
0
Comment
Question by:englishman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 4

Expert Comment

by:siabod
ID: 1863580
If you have a string like this :

<%MyString="men's thoughts"%>

and you insert it into the database, do it like this:

<%sql="insert into tablename (fieldname) values ('"&server.htmlencode(MyString)&"')"%>

The function server.htmlencode handles the apostrophe, when you read it from the database you don't need to do anything

Hope it helps you

0
 
LVL 2

Author Comment

by:englishman
ID: 1863581
I think I get what you mean but the database is not updated online; it is converted from some other format, then uploaded.
0
 
LVL 4

Expert Comment

by:siabod
ID: 1863582
Could you provide more information then ?
cos a normal select wouldn't be doing difficult on it...
0
How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

 
LVL 2

Author Comment

by:englishman
ID: 1863583
Just a normal select on a normal access table.

Keywords = Request.form("Keywords")
q = "SELECT * FROM dbase WHERE Keywords LIKE '%" & Keywords & "%"
(Actually a little more complex but essentially the same)
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1863584
- or -

<%
MyString = replace(MyString, "'", "''")
%>

repace the single' with two ''.  This will also work...
0
 
LVL 2

Author Comment

by:englishman
ID: 1863585
Massey,
You're a star.
Nick
-grab points
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 200 total points
ID: 1863586
Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question