On Jan 17, 2006, at 11:35 AM, Tom Keene wrote:
In REALSQL, the statement db.SQLexecute "INSERT INTO table VALUES
( 'text1', 'text2' )" requires the text to be delimited by single
quotes. So, if the text contains an apostrophe (single quote) it
produces an SQL syntax error.
How can text with an apostrophe be inserted into a table?
You escape single quotes by doubling them. Note that this is two
single quotes together, not one double quote. :)
What I do is have a global method called EscapeQuotes or something
like that. Here's one example of how it could look.
Function EscapeQuotes(RawString as String) as String
Dim S as String
S=ReplaceAll(RawString,"'","''")
Return S
End Function
When it's time to send something to the database, you can call it
like this:
db.SQLExecute "insert into table values ('" + EscapeQuotes(String1) +
"', '" + EscapeQuotes(String2)+"')"
Does that make sense?
--
Brad Rhine
[EMAIL PROTECTED]
http://bradrhine.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>