Inserting statement with single quote

K

kamuixkotori

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'
 
D

Damian S

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.
 
K

kamuixkotori

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?
 
K

kamuixkotori

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top