分页错误???
<%
dim str
set rs = server.createobject("adodb.recordset")
rs.PageSize = 20
rs.CursorLocation=3
str = "select * from cwmxb order by sj"
rs.open str,conn
dim intPage
dim page
dim pre
dim last
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
elseif cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<%
iInt = 1
while not rs.eof and iInt <= 20
%>
<tr>
<td><%=rs("title")%></td>
<td><%=rs("text")%></td>
<td><%=rs("time")%></td>
</tr>
<% iCnt = iCnt + 1
rs.movenext
Wend
%>
</table>
</td>
</tr>
<tr>
<td colspan=6>
<table width="60%" border="0" cellspacing="" align="center" cellpadding>
<tr>
<td bordercolorlight="#000000" bordercolordark="#000000">
<div align="right"><font size="2">
共<%=rs.RecordCount%>条记录
|共<%=rs.PageCount%>页
| 第<%=intpage%>页|
<%if pre then%>
<a href="cw_mingxi.asp?page=<%=intpage - 1%>">上一页</a>
|
<%end if%>
<%if last then%>
<a href="cw_mingxi.asp?page=<%=intpage + 1%>">下一页</a>
|
<%end if%>
<a href="cw_mingxi.asp?page=<%=rs.PageCount%>">最后一页</a>
想做一个简单的分页,现在的问题是:比如我的数据有30条记录,我规定每页显示20条,可是测试的结果是并没有按照两页来显示而是再一个页面里面显示所有的记录,而且下面的上一页、下一页、最后一页链接好像不起作用,请各位帮帮忙,看看是怎么回事,谢谢
问题点数:20、回复次数:9Top
1 楼ddff2004(daniel)回复于 2005-07-21 12:37:51 得分 0
请各位帮忙看看啊Top
2 楼白夜花寒(远藤花已谢,白夜花未寒)回复于 2005-07-21 13:18:13 得分 5
rs.open str,conn,1,3 --->这么试试Top
3 楼ddff2004(daniel)回复于 2005-07-21 13:24:46 得分 0
回复人:白夜花寒(远藤花已谢,白夜花未寒)
谢谢你的回答,可是还是不行。Top
4 楼Grace_pn()回复于 2005-07-21 14:10:29 得分 10
<%
Dim oConn , oRs , sql
dim intPage
dim page
dim pre
dim last
Set oConn=Server.createobject("adodb.connection")
oConn.Cursorlocation = 3
oConn.open "DSN=chum9;UID=susys;PWD=susys;"
Set rs=Server.createobject("adodb.RecordSet")
rs.LockType = 1 'adLockReadOnly
rs.CursorType = 3 'adOpenStatic
sql = "select * from cwmxb order by sj"
rs.Open sql,oConn,0,2,1
rs.PageSize = 20
pre = True
last = True
page = trim(Request.QueryString("page"))
If len(page) = 0 Then
intpage = 1
pre = False
Else
If cint(page) =< 1 Then
intpage = 1
pre = False
Else
If cint(page) >= rs.PageCount Then
intpage = rs.PageCount
last = False
Else
intpage = cint(page)
End If
End If
End If
If not rs.eof Then
rs.AbsolutePage = intpage
End If
%>
<table>
<%
for i=1 to rs.PageSize
If rs.EOF or rs.BOF Then exit for
%>
<tr>
<td><%=rs("title")%></td>
<td><%=rs("text")%></td>
<td><%=rs("time")%></td>
</tr>
<%
rs.movenext
next
%>
</table>
</td>
</tr>
<tr>
<td colspan=6>
<table width="60%" border="0" cellspacing="" align="center" cellpadding>
<tr>
<td bordercolorlight="#000000" bordercolordark="#000000">
<div align="right"><font size="2">
共<%=rs.RecordCount%>条記事
|共<%=rs.PageCount%>頁
| 第<%=intpage%>頁|
<%if pre then%>
<a href="page.asp?page=<%=intpage - 1%>">上一頁</a>
|
<%end if%>
<%if last then%>
<a href="page.asp?page=<%=intpage + 1%>">下一頁</a>
|
<%end if%>
<a href="page.asp?page=<%=rs.PageCount%>">最后一頁</a>
Top
5 楼lsgis2001(程序爱好者)回复于 2005-07-21 14:14:03 得分 5
变量名写错了。
while not rs.eof and iInt<=20
可你下面用的是iCnt=iCnt+1
仔细看看吧。
while not rs.eof and iInt <= 20
%>
<tr>
<td><%=rs("title")%></td>
<td><%=rs("text")%></td>
<td><%=rs("time")%></td>
</tr>
<% iCnt = iCnt + 1
rs.movenext
剩下的自己解决,
送人以鱼不如送人以渔吗!!
呵呵Top
6 楼ddff2004(daniel)回复于 2005-07-21 14:40:45 得分 0
现在内容倒是可以按照规定的条数显示了,可是点击下一页或者上一页的时候不能显示后面的内容????Top
7 楼ddff2004(daniel)回复于 2005-07-22 12:37:50 得分 0
点击下一页或者上一页的时候不能显示后面的内容,不知道为什么,很急啊。。。。Top
8 楼lsgis2001(程序爱好者)回复于 2005-07-22 16:16:10 得分 0
上一页和下一页应该是对的,没看出什么错误来。
点击后有没有什么现象发生?帖出来分析一下。Top
9 楼ddff2004(daniel)回复于 2005-07-22 16:47:44 得分 0
问题已经解决了,程序没有错误,但是在我那个环境下不适合用,现在已经改好了,谢谢大家。结贴Top




