查询分页中,点“下一页”没有反应。

zyy1971 2003-11-20 10:34:12
我用ASP查询ACCESS数据库,有四个字段,用一个表单调用。不知错误出在哪?请高手指教。
源程序如下:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<title>文件查询</title>
<head>
<%
const MaxPerPage=5
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim page
page=1
%>
</head>
<body bgcolor=Thistle>
<P align=center><FONT size=5><strong>文件查询</strong>
<%
word=trim(request("word"))
dim mycon,con
Set con=Server.CreateObject("ADODB.Connection")
mycon= "DRIVER=Microsoft Access Driver (*.mdb);DBQ="&Server.MapPath("/study/search.mdb")
con.open mycon

set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT * FRoM redsearch where id like '%"&word&"%'",MyCon,1,1
if not(rs.eof and rs.bof) then
rs.movefirst
end if

rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1


If trim(Request("word"))<>"" then
CurrentPage= page
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If

if rs.eof then
response.write "<p align='center'> 没有查到要查的记录!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if

dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></P>
<P>    第<%=currentpage%>页,共<%=n%>页。共找到<%=rs.recordcount%> 条符合条件的纪录。</P>
<P>   
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(k-1)+"&word="+word+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b><a href=index.asp?page="+cstr(k+1)+"&word="+word+">下一页</a></b>] "
response.write "[<b><a href='index.asp?page="+cstr(n)+"&word="+word+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>
</P>

<TABLE border=1 align=center>
<tr>
<%

for i= 0 to howmanyfields%>
<TD><div align="center"><B><%=rs(i).name%></B></div></TD>
<%
next

i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields%>

<td> <%=rs(j)%></td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>
...全文
202 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
13617650029 2003-11-23
  • 打赏
  • 举报
回复
这就叫结贴了??
怎么没看到你得分哦
zyy1971 2003-11-23
  • 打赏
  • 举报
回复
结贴了。谢谢。
紫玄青 2003-11-23
  • 打赏
  • 举报
回复
楼主有点不大够意思,我同意楼上的说法,结帐太差了.
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
顶顶。
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
哪位高手在呀,请帮我看一下吧!
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
楼上的(木口兄),不知这一名应怎样改,我是初学者,请帮我一下好吗?
xyzoem2 2003-11-21
  • 打赏
  • 举报
回复
在你的代码中加入response.write("page="&page)
加在你认为可能导致错误的地方,观察page的值是否是错误的,别的等这完了再说
xyzoem2 2003-11-21
  • 打赏
  • 举报
回复
就加在page=1后面
13617650029 2003-11-21
  • 打赏
  • 举报
回复
http://xgjmotor.com/bbs/
里面有一个asp专区
贴子名叫 经过优化的分页代码 强烈推荐
自己看吧
里面有代码和详细的示例~~
还有 我叫酒瓶子 不是楼瓶子 晕倒
呵呵
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
现在有变化了,可是为什么从第一页一下就到了第三页了(总共有三页记录)。
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
(楼瓶子),我的EMAIL:zyy1971@163.com
麻烦你给我发到信箱里,好吗?谢谢!
13617650029 2003-11-21
  • 打赏
  • 举报
回复
我可以提供给你一个多页面通用的分页函数
如果需要 可以联系我的qq
100658100
另外我昨天写了一个多分页函数
1 2 3 4 5 >>
<<4 5 6 7 8
这样的函数
和第一函数一样 也是通用 调用非常简单
代码非常简短 需要可以联系我
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
可他用的是JavaScript,而我用的是VBscript.
DeltaCat 2003-11-21
  • 打赏
  • 举报
回复
lirefea(热色咖啡)代码不是已经给你加了吗?
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
可是这样以后,与page=1这名有冲突。无法通过。
zhang_luo 2003-11-21
  • 打赏
  • 举报
回复
随便加在哪儿,加在你定义变量那里吧
或是要传递参数那语句之前就可以了
要不写在你第二部分<% %>asp代码段里吧
zyy1971 2003-11-21
  • 打赏
  • 举报
回复
我是查询后的分页,page=request("page")要加在哪里?请明示,我是初学者,还弄不清楚。
xyzoem2 2003-11-21
  • 打赏
  • 举报
回复
lirefea(热色咖啡) ( )和alexzhang00(三角猫(sjcatsoft)) 都写了阿
在你的代码里加上page = Request("page")
紫玄青 2003-11-20
  • 打赏
  • 举报
回复
<script language="JavaScript" type="text/JavaScript">
<!--
function return_Page(){
document.pageForm.submit();
}
//-->
</script>

...............
<%
dim Page,Keyword
Page=request("Page")
if Page="0" or isnull(Page) or Page="" then
Page=1
end if
Keyword=request("Keyword")
country=request("country")
select case country
case "0"
sql_country=" "
case ""
sql_country=" "
case else
sql_country=" and country='"&country&"' "
end select
select case Keyword
case ""
sql="select * from custom where 1=1 "&sql_country&" order by date desc"
case else
sql="select * from custom where (username like '%"&Keyword&"%' or truename like '%"&Keyword&"%') "&sql_country&" order by date desc"
end select
rs.open sql,conn,1,1
if not rs.eof then
rs.Pagesize=5
rs.absolutePage=Page
RecordCount=rs.recordcount
PageCount=rs.Pagecount
' response.write pagecount
end if
t1=0
t2=0
do while not rs.eof
t1=t1+1
t2=t2+1
%>
.................
<%
if t1>=5 then exit do
rs.movenext
loop
rs.close
%>
................
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<form name="pageForm" action="">
<tr><td onmouseover="this.bgColor='#ffffff';" onmouseout="this.bgColor='#F9FDFD';" colspan="3" height="3" align=center >
<b><%=checknum(RecordCount)%></b>条信息<% if Page>1 then %>
<a href="Custom_manage.asp?Page=1&Keyword=<%=Keyword%>">首页</a>┊<a href="Custom_manage.asp?Page=<%=(Page-1)%>&Keyword=<%=Keyword%>">上一页</a>┊ <% else%>
<font color=#787878>首页</font>┊<font color=#787878>上一页</font>┊<% end if %><% if cint(Page)<cint(PageCount) then %><a href="Custom_manage.asp?Page=<%=(Page+1)%>&Keyword=<%=Keyword%>">下一页</a>┊<a href="Custom_manage.asp?Page=<%=PageCount%>&Keyword=<%=Keyword%>">尾页</a>┊
<% else %>
<font color=#787878>下一页</font>┊<font color=#787878>尾页</font>┊<% end if %><%=Page%>/<%=PageCount%>页┊5条/页┊转到
<select name="Page" size=1 onChange="return_Page()" <%if Page=0 or Page="" then response.write "disabled"%>><%
for i=1 to PageCount

%>
<option value="<%=i%>" <%if clng(Page)=clng(i) then response.write "selected"%>> <%=i%></option>
<%next%>
</select>页
</td></tr>
<input type=hidden name="Keyword" value="<%=Keyword%>">
</form>
</table>
zyy1971 2003-11-20
  • 打赏
  • 举报
回复
顶顶。
加载更多回复(10)

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧