----- Original Message -----
From: Jeff Dillon <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 15, 1999 6:23 PM
Subject: single quotes in SQL statements


> Can anyone tell me of an easy way to replace a single quote in a string
with
> two single quotes so that I don't get any SQL errors?  I have tried:
>
> myString.replace('\'','\'\'');
>
> and
>
> Char single = '\'';
> Char double = single + single;
>
> myString .replace(single,doulble);
>
> but neither work for obvious reasons...
>
> Thanks for any help.
>
> Jeff Dillon
>
You have to escape the \ in your string as you want the SQL parser to escape
the '

like this "\\'"

Andy Bailey

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to