single quotes imbedded in sql string

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

Guest

Does anyone know how to format an sql query (to avoid errors) when a single
quote is imbedded in a parameter e.g.
select field2 where field1 IN ('abc', 'd'fg','hij').
The ' in d'fg cause an error, but the database field actually contains the
'. Sometimes this is found where feet are abreviated to '
thank you in advance.
 
NJS said:
Does anyone know how to format an sql query (to avoid errors) when a single
quote is imbedded in a parameter e.g.
select field2 where field1 IN ('abc', 'd'fg','hij').
The ' in d'fg cause an error, but the database field actually contains the
'. Sometimes this is found where feet are abreviated to '
thank you in advance.

Double the quotes. E.g. (Access 2000 & greater):

str = "d'fg"
str = Replace(str, "'", "''")
' str now equals "d''fg"
 

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

Back
Top