martindavey
Programmer
Hi,
I'm using ADO to insert into an Access database.
The following works in Access itself:
insert into [myTable] ([First Name],[Surname])
values ("Fred","O'Brien"
In my program I use:
wsprintf( SQL, "insert into [myTable] "
"([First Name],[Surname]) values ('%s','%s');",
strFirstName, strSurname );
...
That works fine, but if the surname contains an apostrophe ( e.g. O'Brien ) then I get syntax error (missing operator).
If I use quotes instead of apostrophes:
wsprintf( SQL, "insert into [myTable] "
"([First Name],[Surname]) values (\"%s\",\"%s\"",
strFirstName, strSurname );
I get Too few parameters (expected 1).
Any idea (I don't want to remove the apostrophe).
Cheers :O)
I'm using ADO to insert into an Access database.
The following works in Access itself:
insert into [myTable] ([First Name],[Surname])
values ("Fred","O'Brien"
In my program I use:
wsprintf( SQL, "insert into [myTable] "
"([First Name],[Surname]) values ('%s','%s');",
strFirstName, strSurname );
...
That works fine, but if the surname contains an apostrophe ( e.g. O'Brien ) then I get syntax error (missing operator).
If I use quotes instead of apostrophes:
wsprintf( SQL, "insert into [myTable] "
"([First Name],[Surname]) values (\"%s\",\"%s\"",
strFirstName, strSurname );
I get Too few parameters (expected 1).
Any idea (I don't want to remove the apostrophe).
Cheers :O)