SQL Search problem

来源: 2004-06-23 11:50:50 [旧帖] [给我悄悄话] 本文已被阅读:

Everytime when the search word contain a ' (ex. Child's)
my search page cause a problem like:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '%'.
search.asp line 103


the following is my code:

SearchFor = TRIM ( Request("searchFor") )
.
.
.
open_statement = "SELECT * from User where Name like '%" & searchFor & "%' "



How can I fix the problem? Thanks so much for your help.