初学制作搜索程序
弄了几个小时,为什么这个程序一运行,电脑明显变慢.而且内存占用量明显
增大.为什么把浏览器关掉后,机子还是越来越慢呢??
还请各位大虾给我看看!! 小弟在此谢过了!!
<!--#include file="conn.asp"-->
<%
dim keyWord,i,sql
i=0
function sqlStr(data)
sqlStr=replace(data,"'","''")
end function
keyWord=sqlStr(request("keyWord"))
keyWord=Rtrim(Ltrim(keyWord))
seachWordTmp=split(keyWord," ") '将输入的字符串根据空格分开,获得一个数组
max=UBound(seachWordTmp) '得出这个数组的维数,即输入的关键字个数
set cmd=server.CreateObject("adodb.command")
set cmd.ActiveConnection=conn
set rs=server.CreateObject("adodb.recordset")
if max=0 then
sql="title like '%"&seachWordTmp(i)&"%'"
else
for i=0 to max
if i=0 then
sql="(title like '%"&seachWordTmp(i)&"%' and "
elseif i=max then
sql=sql&"title like '%"&seachWordTmp(i)&"%' )"
else
sql=sql&"title like '%"&seachWordTmp(i)&"%' and "
end if
next
end if
cmd.CommandText="select title from rich where "&sql&""
set rs=cmd.execute
if not rs.eof or rs.bof then
do while not rs.eof
response.write rs("title")&"<br>"
loop
else
response.write"没有找到结果!"
end if
rs.close
%>
为啥俺的程序一运行,机子就变慢呢??