注册 登录
编程论坛 ASP技术论坛

分页缺少对象问题

zhy328 发布于 2007-09-15 14:58, 989 次点击
这段代码 刚开始没问题 可是后来加了东西后提示说缺少对象,我找了半天也没弄明白那缺少对象
大家帮忙看看那出问题了

<%
Set rs=Server.CreateObject("ADODB.Recordset")
rs.open "select * from products order by id desc",conn,3,1
sumcount=rs.recordcount
if sumcount=0 then
response.Write("no list")
else
page=trim(request("page"))
if page="" then
page=1
end if
rs.pagesize=9
page=cint(page)
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
intPageCount = rs.PageCount
rs.Absolutepage=page
%>


共有<font color="#FF0000"><%=sumcount%></font>条记录 共有<span class="style1"><%=page%><span class="style2">/</span><%=rs.pagecount%></span>页
<%if page<>1 then%>
[<a href="chanpin.asp?page=1">首页</a>][<a href="chanpin.asp?page=<%=page-1%>">上一页</a>]
<%end if%>
<%if page<>rs.pagecount then%>
[<a href="chanpin.asp?page=<%=page+1%>">下一页</a>][<a href="chanpin.asp?page=<%=rs.pagecount%>">尾页</a>]
<%end if%>
9 回复
#2
zsl55662007-09-15 15:01
if not isempty(request.querystring("page")) then
pagecount=cint(request.querystring("page"))
else
pagecount=1
end if
#3
zsl55662007-09-15 15:05
应该是缺少了一个想上面的判断
#4
zhy3282007-09-15 15:09
还是不对啊
#5
zsl55662007-09-15 15:17

<%
if not isempty(request.querystring("page")) then
pagecount=cint(request.querystring("page"))
else
pagecount=1
end if


dim id
id=request("id")
set rs=server.CreateObject("adodb.recordset")
strsql="select * from web_news where sortid="&id
rs.open strsql,conn,3,3
%>
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><img src="image/jiuye_<%=id%>.jpg" width="580" /></td>
</tr>
<tr>
<td>
<br>
<%if rs.bof and rs.eof then %>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25">&nbsp;&nbsp;&nbsp;&nbsp;对不起,暂时没有信息!</td>
</tr>
</table>
<%else
rs.pagesize=30
if pagecount>rs.pagecount or pagecount<=0 then
pagecount=1
end if
rs.AbsolutePage=pagecount
i=1

%>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<%do while not rs.eof
sortid=rs("sortid")
set ra=server.CreateObject("adodb.recordset")
sql="select * from web_news_class where id="&sortid
ra.open sql,conn,3,3
%>

<tr>
<td width="100">【<%=ra("sortname")%>】</td>
<td><a href="jxzx.asp?action=jyzx&id=<%=rs("id")%>"><%=rs("Topic")%></a></td>
<td width="30%"><font color="#999999"><%=rs("updatetimes")%></font></td>
</tr>
<% i=i+1
rs.movenext
if i>=rs.PageSize+1 then exit do
loop
%>
<tr>
<td width="100">&nbsp;</td>
<td colspan="2" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right">共<%=rs.pagecount%>页(<font color="#FF0000"><%=rs.recordcount%></font>)共条信息
<%if pagecount<=1 then%>
首页&nbsp;&nbsp;上一页
<%else%>
<a href="<%=Request.ServerVariables("PATH_INFO")%>?action=kszx&page=1">首页</a>&nbsp;&nbsp;<a href="<%=Request.ServerVariables("PATH_INFO")%>?action=kszx&page=<%=pagecount-1%>">上一页</a>&nbsp;&nbsp;
<%end if %>
<%for page=1 to rs.pagecount%>
<%
if pagecount=page then
link_color="red"
else
link_color=""
end if
%>
[<a href="<%=Request.ServerVariables("PATH_INFO")%>?action=kszx&page=<%=page%>"><font color="<%=link_color%>"><%=page%></font></a>]
<%next%>
<%if pagecount>=rs.pagecount then%>
下一页&nbsp;&nbsp;尾页
<%else%>
<a href="<%=Request.ServerVariables("PATH_INFO")%>?action=kszx&page=<%=pagecount+1%>">下一页</a>&nbsp;&nbsp;<a href="<%=Request.ServerVariables("PATH_INFO")%>?action=kszx&page=<%=rs.pagecount%>">尾页</a>
<%end if %>
<%end if%>

&nbsp; </div></td>
</tr>
</table> </td>
</tr>
</table>
</td>
</tr>
</table>
这是我的分页代码

#6
madpbpl2007-09-15 15:20
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
改成
if page<1 then
page=1
end if
if page>rs.pagecount then
page=rs.pagecount
end if
试试
#7
zhy3282007-09-15 15:30
看不是很明白,我刚学ASP不久
#8
yms1232007-09-15 17:04
报什么错误?
#9
zhy3282007-09-18 11:27
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
改成
if page<1 then
page=1
end if
if page>rs.pagecount then
page=rs.pagecount
end if
多谢各位!!
#10
syuanq2007-09-19 02:02
它是怎样报错的?
1