Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe in Textbox

Status
Not open for further replies.

itorient

Technical User
Feb 20, 2004
29
0
0
US
Hello, I have a textbox for user to fill in. User might fill in an apostrophe. Is there a good way to translate it so when it is inserted in a table, it wouldn't generate an error? Thanks in advance for any expert insight.
 
Use ADO.NET Parameter objects. These will also take care of the case where the user enters a double-quote, a semi-colon, a double-dash, and other invalid characters.

Another benefit is that it protects you from SQL Injection, which is an attack where the bad guy can send arbitrary SQL commands to your database.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
or if you don't want to change all your code and don't worry about security

Code:
replace(txt1.text,"'","''")

but take chiph's advice and change it anyway perhaps not now but certainly in the near future

Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Awesome! It worked! Thank both so much for your insights. I will definitely change it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top