Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to avoid the apostrophe in textbox

Hi,

I allow user to enter its name in a textbox, however, when the name contains apostrophe, e.g. D' Angelo, the SQL statement that update the DB will fail. I don't want to remove the apostrophe from the data, so how could I avoid the failure of executing the SQL in the web page?

Thank you.
[319 byte] By [THL] at [2007-11-11 8:10:20]
# 1 Re: How to avoid the apostrophe in textbox
You can use Replace function. Replace one quote to double quote.

eg:

Replace(str,"'","''")
Sync at 2007-11-11 23:13:25 >
# 2 Re: How to avoid the apostrophe in textbox
...or use a stored procedure instead of a SQL statement.
pclement at 2007-11-11 23:14:25 >