ASP站内搜索问题

2024-11-22 03:52:50
推荐回答(5个)
回答1:

rs.open "SELECT*FORM news where title and key1 like '%"&request.form("key1")"%'"
rs.open conn,adOpenStatie
这两行错了,改一下:悄前
rs.open "SELECT * FORM news where key1 like '%"&request.form("key1")&"%'"启键清,conn,1,1
你的SQL语句也错了,怎么改要看你的查询规则亮哪是什么,上面这行只检索key1字段
如果加上title字段,SQL这么改:
rs.open "SELECT * FORM news where title like '%"&request.form("title")&"%' or key1 like '%"&request.form("key1")&"%'",conn,1,1

回答2:

<%rs.movenext
i=i+1
if i>=count then exit do
loop
%>
那里改成这样的.还有出现了轿哗什么吵喊问题最好说清楚不要说很闭碰行多问题...又没你的原码怎么知道你问题在哪??

回答3:

<%@ Language=VBScript %>

<%
set conn=server.createObject("ADODB.Connection")
dbpath=server.mappath("news.mdb")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq="&dbpath

set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT*FORM news where title like '%"&request.form("title")"%' and key1 like '%"&request.form("key1")"%'"
rs.open conn,adOpenStatie
%>

查询结果



"统计查询共有<% Response.Write(RS.RecordCount) %>条纪录








ID 主题 查看




<% while not rs.eof %>




<% rs.movenext %> <% wend %>
<% =rs("id") %> <% =rs("title") %> ">GO
<% rs.close %>
<% mycon.close %>
"关闭链接

回答4:

rs.open "SELECT*FORM news where title like '% "&request.form("key1")" %'" or key1 like '% "&request.form("key1")" %'"

=========修改=============
在前面定义一个搜所变量

<皮判%@ Language=VBScript %>

<%
set conn=server.createObject("ADODB.Connection")
dbpath=server.mappath("news.mdb")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq="&dbpath
'===============增加下面变量
nowtitle=request.form("title")
nowkey1=request.form("key1")
nowkey2=request.form("key2")
nowkeycontent=request.form("content")

set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT*FORM news where title like '%" nowtitle "%' or key1 like '%" nowkey1 "%' or key2 like '%" nowkey2 "%' or content like '%" nowcontent "%'"
rs.open conn,adOpenStatie
%>

查询结果



"统计查询共有<% Response.Write(RS.RecordCount) %>条纪录<纯物/p>






ID 主题 查看



<燃裤改!--从数据库提取信息-->
<% while not rs.eof %>




<% rs.movenext %> <% wend %>
<% =rs("id") %> <% =rs("title") %> ">GO
<% rs.close %>
<% mycon.close %>
"关闭链接

回答5:

http://zhidao.baidu.com/question/49920083.html'道族消理一样,可做穗渗以防纯脊制