Inserting statement with single quote

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Does anyone know how to insert/update data that contains single quote (')
into a field? Data such as: John's house is in Dalas.

I know one can insert double quote by using single quotes as field
delimiters. But since I have to use single quotes as field delimiters, data
cannot contain single quote. Is there a way to change the field delimiter?

I try escaping the single quote by adding a "\" before the single quote like
the example below, but it still won't work? why? I using Microsoft Access.

'John\'s house is in Dalas'
 
Hi kamuixkotori,

You need to replace single quotes in your SQL String with two single quotes...

eg: strSQL = replace(strSQL, "'", "''")

that's double quote, single quote, double quote
then double quote, two single quotes, double quote

Hope this helps.

Damian.
 
In the SQL view of Microsoft Access it can work.. but in java runtime it give
'java.sql.SQLException: General error' error message.. how come?
 
Hmm.. btw.. it can work already.. thanks a lot!

kamuixkotori said:
In the SQL view of Microsoft Access it can work.. but in java runtime it give
'java.sql.SQLException: General error' error message.. how come?
 
Back
Top