Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I save text which contains an apostrophe (') via sql / odbc Sybase data source in VB?

5 views
Skip to first unread message

Martin Bellerive

unread,
Aug 21, 2000, 3:00:00 AM8/21/00
to
I am writing a database application in VB accessing a Sybase database via
an ODBC connection. While writing text to the db (from text objects) via
the insert or update command I get an error if the user has used an
apostrophe in the text. I am using a single tick ('apostrophe') to delimit
text in the SQL string. Is there a way to change the text delimiter for
the SQL statement or any other means to get around the error when the user
puts an apostrophe in text to be saved?

A sample of a command would be:

[database connection].execute "update dbtable set dbfield='" &
[textfield.text] & "' where primkey = " & primkeytrack & ""

Thank you in advance...

Martin

Eric Murchie-Beyma

unread,
Aug 21, 2000, 3:00:00 AM8/21/00
to
>[database connection].execute "update dbtable set dbfield='" &
>[textfield.text] & "' where primkey = " & primkeytrack & ""


One technique is to pass textfield.text through a function that doubles any
apostrophes it finds. Then use the "doubled-up" copy of the text in your
SQL statement.

John Smirnios

unread,
Aug 22, 2000, 3:00:00 AM8/22/00
to
Or use a host variable (a bound variable) and put the string into a separate
buffer rather than as a text constant in the SQL statement. See the SQLBind*
functions.

-john.

0 new messages