这个是查询语句: sql1="select * from news where (content like '%"&trim(Input)&"%' or title like '%"&trim(Input)&"%') and cateid=0 order by addtime asc" 现在假设INPUT里包含了[]这个字符,为什么就查不出了呢 ? 可能是把[]中的内容当成字段名了吧,SQL中用[]表示字段名, 但能够有什么好的办法可以解决这个问题吗?
问题得以解决,感谢各位
我是这么解决的:
Input=request("FileNum")
Input=replace(Input,"[","%' or fileno like '%")
sql1="select * from news where fileno like '%"&trim(Input)&"%' order by addtime asc"
如查询: 国科发政字[2003]416
Input的内容是:“国科发政字[2003]416 ”
SQL的执行语句是:
select * from news where fileno like '%国科发政字%' or fileno like '%2003]416%' order by addtime asc
select * from news where (content like '%国科发政字\[2003\]416%' {escape '\'} or title like '%国科发政字\[2003\]416%'{escape '\'{escape '\'} and cateid=0 order by addtime asc
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e21'
Input=replace(Input,"[","\[")
Input=replace(Input,"]","\]")
sql1="select * from news where (content like '%"&trim(Input)&"%' {escape '\'} or title like '%"&trim(Input)&"%' {escape '\'}) and cateid=0 order by addtime asc"