Hi all,
i'm trying to input a string into a table in a database via vba from an excel sheet, my problem is that every so often a string will have a name like " mr 'ben' " which errors as ' is a special character
what do i do?
Replace ' with '' before you try and add it.
unfortunately i'm reading the strings in from a file, there are many thousands of them so going through 1 by one would not really be an option!
Where did I suggest you should do that? You do it in code.
what like:
?VALUES ("" & Cells(y, x).Value & "",
Last edited by romperstomper; 11-08-2010 at 11:16 AM. Reason: correct tags
More like:
assuming that's how you are doing the update, or do a global replace on the whole sheet first.VALUES (" & Replace(Cells(y, x).Value, "'","''") & "
hmm that gives me a missing operator error![]()
: syntax error (missing operator) in query expression 'bbc 1'
Typo as you need quotes around the values:
VALUES ('" & Replace(Cells(y, x).Value, "'","''") & "'"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks