请大家帮我看看调试一下这个翻页程序!

hhht2003 2003-09-15 11:17:32
我的翻页程序如下:
<!-- #Include File=conn.asp -->

<table width="630" border="0" cellspacing="0" cellpadding="0" align="center" height="286" background="../image/bg01.jpg">
<tr>
<td width="445" valign="top" align="left" height="298">
<%
sql="select * from enterprise_register "
rs.Open sql,conn,1,1
rs.PageSize =2
if Not Isempty(Request("ToPage")) then

ToPage = CInt(Request("ToPage"))
'则将它设定为最后一页
if ToPage > RS.PageCount then
RS.AbsolutePage = RS.PageCount
elseif ToPage <= 0 then
RS.AbsolutePage = 1
else
'将记录指针设定欲检视的分页
RS.AbsolutePage = ToPage
end if
End if
Current_Page=rs.absolutepage '''''这的值current_page总是"-1"
%>
<H3 align="left" style="margin-top: -1; margin-bottom: -1"> 
</H3>
<H3 align="left" style="margin-top: -1; margin-bottom: -1"><font size="2" color="#000080">目前的分页状况为<FONT SIZE = 4 COLOR = red>
<% = Current_Page %>/<% = RS.PageCount %></FONT>页</font>
</H3>
<p align="left" style="margin-top: -1; margin-bottom: -1"> 
</p>
<%
Display_Page RS,Current_page
%>
<TABLE width="580" algin="right">
<TR valign=baseline align=right>
<%
if Current_Page <> 1 then
%>
<TD Width=145 align="right">
<p align="left">
<A Href=gzfy.asp?ToPage=<% = 1%>>第一页</A>
</p>
</TD>
<TD Width=145>
<p align="left">
<A Href=gzfy.asp?ToPage=<% =Current_Page- 1%>>上一页</A>
</p>
</TD>
<%
end if

if Current_Page <> RS.PageCount then
%>
<TD Width=145>
<p align="left">
<A Href=gzfy.asp?ToPage=<% = Current_Page + 1%>>下一页</A>
</p>
</TD>
<TD Width=144>
<p align="left">
<A Href=gzfy.asp?ToPage=<% = RS.PageCount%>>最后一页</A>
</p>
</TD>

<%
end if
%>

<TD Width=132 algin="right">
<FORM action=gzfy.asp method=POST>
<p align="left">
<!--在此提供一个给用户输入页数的字段 -->

<INPUT type="text" name=ToPage style="HEIGHT: 25px; WIDTH: 40px"
value=<% = CurrentPage%>> 页
</FORM></TD></TR>
</TABLE>

<%
Set RS = Nothing '重设RS对象
%>
<%Sub Display_Page(RS,page)
'设定记录指针指向的页数
' RS.AbsolutePage=page
'先在表格上方填入数据域位%>
<%'利用For循环配合PageSize属性输出一页中的记录
For i = 1 to RS.PageSize
'先使用if判断在最后一页记录时,是否有
'将记录指针移至最后一条记录之后
if RS.EOF then
Exit For '跳出For循环
end if
Row = "<TR BGCOLOR=#FFFF00> <TD>" & RS.AbsolutePosition & "</TD>"
%>

<table border="0" width="118%" algin="right" cellspacing="2" cellpadding="2" background="image/bg01.jpg">
<tr>
<td width="5%"><% Row = "<TR BGCOLOR=#cfdafa> <TD>" & RS.AbsolutePosition & "</TD>"
response.write row %></td>
<td width="60%" algin="left" align="left">
<p align="left"><font color="#000080"><a href="gzfyshow.asp?bt=<%=rs(1)%> " >
<%=rs(1)%></font></a></td>
<td width="25%" align="left">
<p align="left"><font color="#000080"><%=rs(4)%></font></td>


</tr>
</table>

<% RS.MoveNext
next
End Sub %>


</table>

Current_Page=rs.absolutepage '''''这的值current_page总是"-1"


...全文
48 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhht2003 2003-09-17
  • 打赏
  • 举报
回复
谢谢调试成功!
这个程序是我以前用过的,
后来我重装了机器后就不能用了,这是书上的例题.
以前都能调试通过的,不知道怎么回事了,不能用了..
makthy 2003-09-17
  • 打赏
  • 举报
回复
呵呵,我也是个新手呀,学asp没有几天呀。
hhht2003 2003-09-16
  • 打赏
  • 举报
回复

rs.AbsolutePage =page

还是提示这行错误.
makthy 2003-09-16
  • 打赏
  • 举报
回复
你把这个程序拷贝到你的机器上试一试
<!-- #Include File=conn.asp -->
<% sql="select * from enterprise_register "
set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,3
rs.PageSize =2
if Not Isempty(Request("page")) then
nowpage=request("page")
if nowpage <1 then
rs.AbsolutePage = 1
elseif nowpage > rs.PageCount then
rs.AbsolutePage = RS.PageCount
else
rs.AbsolutePage = nowpage
end if
End if
%>

<table width="630" border="0" cellspacing="0" cellpadding="0" align="center" height="286" >
<tr>
<td width="445" valign="top" align="left" height="298">
<H3 align="left" style="margin-top: -1; margin-bottom: -1"> 
</H3>
<H3 align="left" style="margin-top: -1; margin-bottom: -1"><font size="2" color="#000080">目前的分页状况为<FONT SIZE = 4 COLOR = red>
<% = nowpage %>/<% = rs.PageCount %></FONT>页</font>
</H3>
<p align="left" style="margin-top: -1; margin-bottom: -1"> 
</p>
<%
Display_Page rs,nowpage
%>
<TABLE width="580" algin="right">
<TR valign=baseline align=right>
<%
if nowpagee <> 1 then
%>
<TD align="right">
<p align="left">
<A Href=gzfy.asp?page=<%=1%>>第一页</A>
</p>
</TD>
<TD >
<p align="left">
<A Href=gzfy.asp?page=<%=nowpage-1%>>上一页</A>
</p>
</TD>
<%
end if

if nowpage <> rs.PageCount then
%>
<TD>
<p align="left">
<A Href=gzfy.asp?page=<%=nowpage+1%>>下一页</A>
</p>
</TD>
<TD >
<p align="left">
<A href=gzfy.asp?page=<%=rs.PageCount%>>最后一页</A>
</p>
</TD>

<%
end if
%>

<TD algin="right">
<FORM action=gzfy.asp method=POST>
<p align="left">
<!--在此提供一个给用户输入页数的字段 -->

<INPUT type="text" name=page style="HEIGHT: 25px; WIDTH: 40px"
value=<%=nowPage%>>页<input type="submit" value="GO">
</FORM></TD></TR>
</TABLE>

<%
Set rs = Nothing '重设RS对象
%>

<%Sub Display_Page(rs,page)
'设定记录指针指向的页数
if page<=1 then
page=1
end if
rs.AbsolutePage =page
'先在表格上方填入数据域位%>
<%'利用For循环配合PageSize属性输出一页中的记录
For i = 1 to RS.PageSize
'先使用if判断在最后一页记录时,是否有
'将记录指针移至最后一条记录之后
if RS.EOF then
Exit For '跳出For循环
end if
Row = "<TR BGCOLOR=#FFFF00> <TD>" & RS.AbsolutePosition & "</TD>"
%>

<table border="0" width="118%" algin="right" cellspacing="2" cellpadding="2" background="image/bg01.jpg">
<tr>
<td width="5%"><% Row = "<TR BGCOLOR=#cfdafa> <TD>" & RS.AbsolutePosition & "</TD>"
response.write row %></td>
<td width="60%" algin="left" align="left">
<p align="left"><font color="#000080"><a href="gzfyshow.asp?bt=<%=rs(1)%> " >
<%=rs(1)%></font></a></td>
<td width="25%" align="left">
<p align="left"><font color="#000080"><%=rs(4)%></font></td>


</tr>
</table>

<% RS.MoveNext
next
End Sub %>
makthy 2003-09-15
  • 打赏
  • 举报
回复
对了,你把我改后的777.asp改为你的网页的名字gzfy.asp
makthy 2003-09-15
  • 打赏
  • 举报
回复
你看一下我改后的程序,应该没问题的呀,我试过了

<!-- #Include File=conn.asp -->
<table width="630" border="0" cellspacing="0" cellpadding="0" align="center" height="286" background="../image/bg01.jpg">
<tr>
<td width="445" valign="top" align="left" height="298">
<%

sql="select * from enterprise_register "
set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,conn,1,3
rs.PageSize =2
if Not Isempty(Request("page")) then

nowpage=request.QueryString("page")
'则将它设定为最后一页
if nowpage > rs.PageCount then
rs.AbsolutePage = RS.PageCount
elseif nowpage <= 0 then
rs.AbsolutePage = 1
else
'将记录指针设定欲检视的分页
rs.AbsolutePage = nowpage
end if
End if
'rs.absolutepage=nowpage
%>
<H3 align="left" style="margin-top: -1; margin-bottom: -1"> 
</H3>
<H3 align="left" style="margin-top: -1; margin-bottom: -1"><font size="2" color="#000080">目前的分页状况为<FONT SIZE = 4 COLOR = red>
<% = nowpage %>/<% = rs.PageCount %></FONT>页</font>
</H3>
<p align="left" style="margin-top: -1; margin-bottom: -1"> 
</p>
<%
Display_Page rs,nowpage
%>
<TABLE width="580" algin="right">
<TR valign=baseline align=right>
<%
if nowpagee <> 1 then
%>
<TD Width=145 align="right">
<p align="left">
<A Href=gzfy.asp?page=<%=1%>>第一页</A>
</p>
</TD>
<TD Width=145>
<p align="left">
<A Href=777.asp?page=<%=nowpage-1%>>上一页</A>
</p>
</TD>
<%
end if

if nowpage <> rs.PageCount then
%>
<TD Width=145>
<p align="left">
<A Href=777.asp?page=<%=nowpage+1%>>下一页</A>
</p>
</TD>
<TD Width=144>
<p align="left">
<A href=gzfy.asp?page=<%=rs.PageCount%>>最后一页</A>
</p>
</TD>

<%
end if
%>

<TD Width=132 algin="right">
<FORM action=777.asp method=POST>
<p align="left">
<!--在此提供一个给用户输入页数的字段 -->

<INPUT type="text" name=page style="HEIGHT: 25px; WIDTH: 40px"
value=<%=nowPage%>> 页
</FORM></TD></TR>
</TABLE>

<%
Set rs = Nothing '重设RS对象
%>

<%Sub Display_Page(rs,page)
'设定记录指针指向的页数
rs.AbsolutePage =page
'先在表格上方填入数据域位%>
<%'利用For循环配合PageSize属性输出一页中的记录
For i = 1 to RS.PageSize
'先使用if判断在最后一页记录时,是否有
'将记录指针移至最后一条记录之后
if RS.EOF then
Exit For '跳出For循环
end if
Row = "<TR BGCOLOR=#FFFF00> <TD>" & RS.AbsolutePosition & "</TD>"
%>

<table border="0" width="118%" algin="right" cellspacing="2" cellpadding="2" background="image/bg01.jpg">
<tr>
<td width="5%"><% Row = "<TR BGCOLOR=#cfdafa> <TD>" & RS.AbsolutePosition & "</TD>"
response.write row %></td>
<td width="60%" algin="left" align="left">
<p align="left"><font color="#000080"><a href="gzfyshow.asp?bt=<%=rs(1)%> " >
<%=rs(1)%></font></a></td>
<td width="25%" align="left">
<p align="left"><font color="#000080"><%=rs(4)%></font></td>


</tr>
</table>

<% RS.MoveNext
next
End Sub %>
hhht2003 2003-09-15
  • 打赏
  • 举报
回复
不行啊
Primer2002cn 2003-09-15
  • 打赏
  • 举报
回复
sql="select * from enterprise_register "
rs.Open sql,conn,3,1 '这里要改一下
rs.PageSize =2

28,391

社区成员

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

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