停止用户输入'char

Phi*_*hil 2 sql asp.net string validation

我有一个搜索页面,我想阻止用户输入'到文本框,或用合适的字符替换它.任何人都可以帮助我在asp.net vb中实现这一目标吗?

例如,如果用户搜索O'Reilly,则搜索会因错误而崩溃:

Line 1: Incorrect syntax near 'Reilly'. Unclosed quotation mark before the character string ' '.
Run Code Online (Sandbox Code Playgroud)

谢谢!

Mat*_*hen 7

正确使用参数化语句,这将为您处理.