Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

Insert single quote in Classic ASP

Hi Experts,
I'm trying to insert last names like O'Neil into my database, but it gives me an error because of the single quote in the last name.
It works with names without single quotes.
This is how I'm doing it:

sLast_Name=rs2("Last_Name")

Ho can I rewrite this so that it accepts single quotes.

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
of course, using parameterized queries would be much simpler and safer to do
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stefan Motz

ASKER

Thank you very much for your help. This also solved the problem:

sLast_Name=replace(rs2("Last_Name"),"'","''")