主题:  我做了个查询页面为什么老是超时呀?

谁染枫林醉

职务:普通成员
等级:1
金币:1.0
发贴:148
#12003/12/28 18:35:20
chaxun.asp

<!--#include file="public/conn.asp"-->
<!--#include file="public/TurnPage.asp"-->
<LINK href="style.css" type=text/css rel=stylesheet>
<%
dim sql,rs
set rs=server.createobject("abodb.recordset")
sql="selcet * from test where name like %'"&key&"'% or qq like %'"&key&"'% or mail like %'"&key&"'% or add like %'"&key&"'% or other like %'"&key&"'%"
rs.open sql,conn,1,1
%>
Dim RowCount
RowCount = 10
Call TurnPage(rs,RowCount)
%>
<%if rowcont=0 then response.write "不好意思,找不到撒"%>
<%
if not rs.eof then
Do while Not Rs.eof and RowCount>0
%>
<%=rs("id")%>&nbsp;<font color=#6600CC>昵称:</font>&nbsp;<%=rs("user")%>&nbsp;<font color=#6600CC>QQ:</font>&nbsp;<%=rs("qq")%>&nbsp;<font color=#6600CC>地址:</font>&nbsp;<%=rs("add")%>&nbsp;<font color=#6600CC>邮件:</font>&nbsp;<%=rs("mail")%>&nbsp;<font color=#6600CC>其它:</font>&nbsp;<%=rs("other")%><BR>
<% if session("admin") <> "" then %>
     |&nbsp;&nbsp;<a href="delete.asp?ID=<%=rs("ID")%>">删除&nbsp;&nbsp;|</a>
     <%end if%><HR>
<%
RowCount = RowCount - 1
rs.movenext
loop
End If
%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<font color=yellow size=2><center>本程序由蛙蛙王子编写而成的,呵呵。<BR>Copyright (C) 2003 蛙蛙, All Rights Reserved 版权所有</center></font>

conn.asp

<%
dim conn,connstr
on error resume next
connstr="DBQ="+server.mappath("test.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set conn=Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>

turnpage.asp

<%
'+++++++++++++++++++++++++++++++++++++
'◆文 件 名: TurnPage.asp
'◆传入参数: Rs_tmp (记录集), PageSize (每页显示的记录条数)
'◆输 出: 记录集翻页显示功能
'+++++++++++++++++++++++++++++++++++++
'
Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If

'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<table border=0 width='100%'>
<tr>
<td align=left> 总页数:<font color=yellow><%=TotalPage%></font>页
当前第<font color=yellow><%=PageNo%></font>页</td>
<td align="right">
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "首页|前页|后页|末页"
Else%>
<a href="<%=fileName%>?PageNo=1">首页|</a>
<%If PageNo - 1 = 0 Then
Response.Write "前页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前页|</a>
<%End If

If PageNo+1 > TotalPage Then
Response.Write "后页|"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后页|</a>
<%End If%>

<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末页</a>
<%End If%></td>
<td width=95>转到第
<%If TotalPage = 1 Then%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input type=text name=PageNo size=3 value="" title=请输入页号,然后回车>
<%End If%>页
</td>
</tr>
</table>
<%End Sub%>



谁染枫林醉

职务:普通成员
等级:1
金币:1.0
发贴:148
#22003/12/28 18:36:19
晕,应该做个关闭表情符号转换的选项,这样贴代码就贴不错了,



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#32003/12/28 19:08:53
建议你在定义变量,给数据库的表,字段命名的时候加上相应的前缀,增加阅读性,也避免了一些不必要的误解.比如sql里面的关键字~



谁染枫林醉

职务:普通成员
等级:1
金币:1.0
发贴:148
#42003/12/28 21:29:39
哦,也是,谢谢你的提醒哦,不过偶的代码到底哪里出错了呀?



谁染枫林醉

职务:普通成员
等级:1
金币:1.0
发贴:148
#52003/12/29 1:57:31
晕,我好象忘了定义KEY了