请教:ASP数据库搜索某一特定字符或数据代码怎么编呀?

来源:百度知道 编辑:UC知道 时间:2024/09/23 22:30:53
<%
dim khdm
khdm=replace(request.querystring("s"),"'","")
If khdm = "" Then
Response.Redirect( "fanxiuchaxun.asp" )
End If
exec="select*from wxsj where khdm like '%"&khdm&"%' order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3
%>
不对,这么编是搜索相近的某一类,而不是所有字必须相同的.

如果是所有字都相同的话也不需要写成这个样子的
把原来的exec改成
exec="select * from wxsj where khdm='"&khdm&"' order by id desc"

这么编不是搜索相近的某一类,而是搜索数据库中 wxsj字段 所有包含khdm变量的值(应该是一个字符串,例如"abc")的记录,例如 aabc abcc aabcc 这样的记录都会被搜出来。你要想所有字必须相同的话,那就把前后的%(通配符)掉,去掉后只匹配完全一样的。

like直接换等号。。。。
Select * from wxsj where khdm ='"&khdm&"'

就这么编