Using SQL to INSERT a string with quotes

D

Dave

I am trying to use SQL to insert a text string that contains quotes into an
Access 2002 table.

My INSERT statement looks something like this:

INSERT INTO ResearchArticle (ResearchID, ArticleID, Summary) VALUES( 17,
1371,"The president said, "I do believe it to be so." when asked by the
press.")

This generates the following error:

ERROR: F_Article_Post_to_Research.cmdPost_Click
5/15/2005 12:52:22 AM
Err.Number: 3075
Err.Description: Syntax error (missing operator) in query expression "The
president said, "I do believe it to be so." when asked by the press"


How can I use SQL to INSERT a string containing quotes?

Do I have to do some kind of find and replace or can I enclose the string in
some kind of escape characters?

I would prefer not to use the recordset AddNew/Update methods but if that is
my only option, please let me know.
 
S

Steve Schapel

Dave,

Try it like this...
strSQL = "INSERT INTO ResearchArticle (ResearchID, ArticleID, Summary)
VALUES ( 17,1371,'The president said, " & """I do believe it to be
so.""" & " when asked by the press.' )"
 
V

Van T. Dinh

Try:

INSERT INTO ResearchArticle (ResearchID, ArticleID, Summary) VALUES( 17,
1371,"The president said, ""I do believe it to be so."" when asked by the
press.")
 

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