Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access SQL insert with apostrophe problem...

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
I am trying to insert into Access using a method of the CDatabase class.

I have a variable that contains a surname that may well contain an apostrophe, eg. O'Reily.

My SQL insert is:

strSQL.Format("insert into [myTable] (Surname) ('%s')",
strSurname );

I get a syntax error on inserting because of the apostrophe in the surname.

I have tried using escaped quotes, and brackets but to no avail.

Removing the apostrophe is not an option.

Thanks, Martin :O|
 
Simply replace the apostrophe with two:

O'Reilly becomes O''Reilly.

Then it will work.
 
Hey exactly how do i write an INSERT statement in ADO using Visual C++ tell me the exact syntax for example:
Table Name: employee
column name: Employee Name
Value: "ramu";

how can i insert this in ADO usig visual c++..tell me exatly (the full syntax) including the double and dingle quotes..i am not using MFC..i am writina simple win32 dll with #importing msado15.dll..

pls reply soon to ramsir@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top