'``````````````````````````````````````````
' 处理检索的程序,包括在结果中进行再次查询
'``````````````````````````````````````````
session("num")=session("num")+1 '记录二次检索的次数
session(session("num"))=trim(request("Conque")) 'varN1--每次新的检索条件
iNum=session("num")
strQ1=" "
strQ2=" "
if iNum=1 then
strQ1=" mag_name like '%" & session(iNum) & "%'"
'strQ2=" mag_department like '%" & session(iNum) & "%'"
else
strQ1=" and mag_name like '%" & session(iNum) & "%'"
'strQ2=" and mag_department like '%" & session(iNum) & "%'"
end if
session("str1")=session("str1") & strQ1
'session("str2")=session("str2") & strQ2
sql="select * from magazine_tab where "
sql=sql & session("str1")' & " or " & session("str2")
set rs=cnn.execute(sql)
do until rs.eof
response.write(rs(1))
response.write(rs(2)&"<br>")
rs.movenext
loop
rs.close
cnn.close
set rs=nothing
set cnn=nothing
<script language=vbscript runat=server>
sub session_onstart
session("num")=0
end sub
sub session_onend
session("num")=0
session("num").abandon
for i=1 to session("num")
session(i).abandon
next
session("key").abandon
end sub
</script>
search.asp
<!-- include file="../inc/conn.asp" -->
<script language="javascript">
function Check()
{
if(search.key.value=="请输入关键字" )
{alert("请输入检索关键词!");
search.key.focus();
return(false);}
if(search.key.value=="" )
{alert("请输入检索关键词!");
search.key.focus();
return(false);}
<!-- #include file="../inc/conn.asp" -->
<script language="javascript">
function Check()
{
if(secsearch.xs.value=="")
{alert("请输入二次检索关键词!");
secsearch.xs.focus();
return(false);}
}
</script>
<%
if session("num")=0 then
session("key")=trim(request.form("key"))
end if
session("num")=session("num")+1
session(session("num"))=trim(request.form("xs"))
%>
<%
sql="select * from thesis_tab where thesis_title like '%"&session("key")&"%'"
for j=2 to session("num")
sql=sql&"and thesis_title like '%"&session(j)&"%'"
next
response.write sql
set rs=conn.execute(sql)
%>
<table border="1" cellpadding="0" cellspacing="0" width="90%" style="font-family: 宋体; font-size: 9pt; word-spacing: 0; margin: 0" bordercolor="#000080" bordercolorlight="#000080" bordercolordark="#FFFFFF">
<%while not rs.eof
%>
可以使用recordset对象的filter方法来实现
Exp
Set conn=server.createobject("adodb.connection")
conn.open "DSN=test;UID=zorou;PWD=zorou"
Set rst=server.createobject("adodb.recordset")
rst.open "select * from tablename order by id desc",conn,2,3
if rst.eof then
response.write "目前无记录"
else
rst.Filter="id=1"
while not rst.eof
response.write rst("id")
rst.movenext
wend
end if