柜式空调报价:请问,在asp里的站内搜索如何实现精确查询

来源:百度文库 编辑:中科新闻网 时间:2024/05/04 02:25:54
<%
keyword=request("keyword")
%>

<%
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.mappath("data/xxx.mdb")+";Persist Security Info=False"
set conn = Server.CreateObject("ADODB.Connection")
conn.open strConn
set rs=server.CreateObject("adodb.recordset")

'查询“leibie”表,"fangshi"字段,“keyword”关键字
sql="select * from 1 where 2 like '%"&keyword&"%' order by id desc"
rs.open sql,conn,1,3
if page<=0 then page=1
if request.QueryString("page")="" then
page=1
end if
<!--添加部分-->
If rs.EOF AND rs.BOF Then
Response.Write(" 暂时没有")
else
end if
%>

这段是模糊搜索的代码,如果我要实现精确查询,要怎么实现,我试过将like改为=,它就说“标准表达式中数据类型不匹配”。还有,上面如果没有查询信息,它就说操作需要一个真的记录,添加部分的代码不起作用
。请大家提供一段代码。

sql="select * from 1 where 2 like '%"&keyword&"%' order by id desc"

改为

sql="select * from 1 where 2 = '"&keyword&"' order by id desc"

注意要把百分号也删掉。百分号只有用like才需要。