请哪位朋友看一下我这个分页的程序哪里有错了?

coolming 2003-08-21 03:36:34
错误类型:
Microsoft VBScript 运行时错误 (0x800A000B)
/flowersite/page.asp, 第 98 行
----------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
set conn=server.CreateObject ("adodb.connection")
conn.Open "driver={sql server};server=localhost;uid=sa;pwd=sa;database=hw"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> 分页</title>
</head>

<body>

<table width="195" border="0" cellspacing="0" cellpadding="0">
<%
const maxperpage=2
dim totalput
dim currentpage
dim totalpages
if not isempty(request("page")) then
currentpage=cint(request("page"))
else
currentpage=1
end if
set rs=server.CreateObject ("adodb.recordset")
rs.Open "select * from flower",conn,1,1
if err.number<>0 then
Response.Write "数据库中无数据!"
end if
if rs.EOF and rs.BOF then
Response.Write "暂时没有更新鲜花!"
else
totalput=rs.RecordCount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*maxperpage>totalput then
if(totalput mod maxperpage)=0 then
currentpage=totalput/maxperpage
else
currentpage=totalput/maxperpage+1
end if
end if
if currentpage=1 then
showcontent
showpage totalput,maxperapge,"page.asp"
else
if (currentpage-1)*maxperpage<totalput then
rs.Move (currentpage-1)*maxperpage
dim bookmark
bookmark=rs.Bookmark
showcontent
showpage totalput,maxperpage,"page.asp"
else
currentpage=1
showcontent
showpage totalput,maxperpage,"page.asp"
end if
end if

end if

sub showcontent
dim i
i=0
%>
<%
do while not rs.EOF
%>
<tr>
<td width="195">

<table width="189" height="94" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="80" rowspan="3"><img name="" src="<%=rs("f_pic")%>" width="84" height="93" alt=""></td>
<td width="109">花名<%=rs("f_name")%></td>
</tr>
<tr>
<td height="14">价格<%=rs("f_price")%></td>
</tr>
<tr>
<td valign="top">简介:<%=rs("f_info")%></td>
</tr>
</table></td>
</tr><%
i=i+1
if i>=maxperpage then exit do
rs.MoveNext
loop
rs.Close
set rs=nothing
%><%
end sub

Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If

Response.Write "<form method=Post action="&filename&" id=form1 name=form1>"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1 class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&" class='contents'>上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"种商品 "&maxperpage&"种商品/页</font> "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok'></form>"
End Function
%>
</table>


</body>
</html>

...全文
25 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
椰子 2003-08-21
  • 打赏
  • 举报
回复
const maxperpage=2
Function showpage(totalnumber,maxperpage,filename)
是不是这两行冲突了?!
你开始将maxperpage定义为常量
后来又定义为参数
这样不行吧??!
改一下试试


xxrl 2003-08-21
  • 打赏
  • 举报
回复
以后不要自己写分页程序了,因为有模板,呵呵,如下:当然,如果不需要那就算了,呵呵

<%
'+++++++++++++++++++++++++++++++++++++
'◆模块名称: 公共翻页模块
'◆文 件 名: 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=#ff3333><%=TotalPage%></font>页
当前第<font color=#ff3333><%=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>
</tr>
</table>
<%End Sub%>

椰子 2003-08-21
  • 打赏
  • 举报
回复
就是啊!这么长怎么看啊!?·我都数晕了?!
wandola 2003-08-21
  • 打赏
  • 举报
回复
不知道你98行在哪里??

28,390

社区成员

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

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