ASP带参数分页传递问题,不能分页,高手求助!!

szlx169 2009-09-01 09:30:40
代码如下:可以查询出来,但点击第二页就说 参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
这代码是抄网页的,不知道哪里错。



<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/ttl.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("type") <> "") Then
Recordset1__MMColParam = Request.QueryString("type")
End If
%>
<%
Dim I
Dim RPP
Dim PageNo
I=1
RPP=3
PageNo=CInt(Request("PageNo"))
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_ttl_STRING
Recordset1.Source = "SELECT * FROM pic WHERE type = '" + Replace(Recordset1__MMColParam, "'", "''") + "' ORDER BY id DESC"
Recordset1.CursorType = 1
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
Recordset1.PageSize=RPP
If PageNo<=0 Then PageNo=1
If PageNo>Recordset1.PageCount Then PageNo=Recordset1.PageCount
Recordset1.AbsolutePage= CLng(PageNo) (错误地方,取消该行,可以显示,且有分页数字,但点击第2页后就不行了,不显示结果)

Sub ShowPageInfo(tPageCount,cPageNo)
Response.Write "第"&cPageNo&"页[共"&tPageCount&"页]"
End Sub

Sub ShowPageNavi(tPageCount,cPageNo)
If cPageNo<1 Then cPageNo=1
If tPageCount<1 Then tPageCount=1
If cPageNo>tPageCount Then cPageNo=tPageCount
Dim NaviLength
NaviLength=tPageCount
Dim I,StartPage,EndPage
StartPage=(cPageNo\NaviLength)*NaviLength+1
If (cPageNo Mod NaviLength)=0 Then StartPage=StartPage-NaviLength
EndPage=StartPage+NaviLength-1
If EndPage>tPageCount Then EndPage=tPageCount
If StartPage>1 Then
Response.Write "<a class=""pageNavi"" href=""?PageNo=" & (cPageNo-NaviLength) & """><<</a> "
Else
Response.Write "<font color=""#CCCCCC""><<</font> "
End If
For I=StartPage To EndPage
If I=cPageNo Then
Response.Write "<b>"&I&"</b>"
Else
Response.Write "<a class=""pageNavi"" href=""?PageNo=" & I & """>" & I & "</a>"
End If
If I<>tPageCount Then Response.Write " "
Next
If EndPage<tPageCount Then
Response.Write " <a class=""pageNavi"" href=""?PageNo=" & (cPageNo+NaviLength) & """>>></a>"
Else
Response.Write " <font color=""#CCCCCC"">>></font> "
End If
End Sub

%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_ttl_STRING
Recordset2.Source = "SELECT * FROM type ORDER BY ID1 ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
...全文
290 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
szlx169 2009-09-05
  • 打赏
  • 举报
回复
ASP带参数分页传递问题,不能分页,高手求助!!
szlx169 2009-09-04
  • 打赏
  • 举报
回复
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲
loveinet_168 2009-09-02
  • 打赏
  • 举报
回复
是不是点上一页,下一页的时候链接出了问题?请检查一下。
szlx169 2009-09-02
  • 打赏
  • 举报
回复
加了参数,没有点击左边菜单,数据库没有记录,点击左边菜单搜索后,有记录了,出现不能分页问题
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 number123456 的回复:]
你数据库里有记录吗?
[/Quote]


说明一下,这里有二个数据表单,一个是商品项目类,一个是产品信息类,点击左边商品各项目菜单时,右边能显示各项同一类商品的图片,这个功能已实现。就是分页时不能自动分(能显示1、2、3、4。。。。分页码,点击第2页以后就不能显示)


Recordset1.AbsolutePage= PageNo 提示有错误,取消此行内容,网页正常,且可以显示分页数,点击第2页后就没显示了。。。
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 number123456 的回复:]
你数据库里有记录吗?
[/Quote]


有记录的。
Recordset1.AbsolutePage= PageNo (出错地方,取消该行,可以显示,且有分页数字,但点击第2页后就不行了,不显示结果)
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 number123456 的回复:]
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=PageNo

在最前边加上一个PageNo = trim(PageNo)试试有提示吗?
一般情况下Recordset1.AbsolutePage的值只要是大于等于1,小于Recordset1.PageCount的数字就行,我以前碰到过类似的提示,主要是PageNo(当前页数)的值不正确,或者不是数字,或者为空,所以只要保证在absolutepage赋值之前,PageNo能过各种判断,保证是数字就应该没问题了
[/Quote]


取消参数可以分页,网页正常" + Replace(Recordset1__MMColParam, "'", "''") + "'

但加了参数就不能分页。。。。
number123456 2009-09-01
  • 打赏
  • 举报
回复
你数据库里有记录吗?
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 number123456 的回复:]
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=PageNo

已试过,不行。
在最前边加上一个PageNo = trim(PageNo),

[color=#FF0000]PageNo = trim(PageNo)

PageNo=Cint(Request("PageNo"))
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_ttl_STRING
Recordset1.Source = "SELECT * FROM pic WHERE type = '" + Replace(Recordset1__MMColParam, "'", "''") + "' ORDER BY id DESC"
Recordset1.CursorType =3
Recordset1.CursorLocation = 3
Recordset1.LockType = 3
Recordset1.Open()

Recordset1_numRows = 0
Recordset1.PageSize=RPP
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=PageNo



Recordset1.AbsolutePage=PageNo[/color]提示参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
number123456 2009-09-01
  • 打赏
  • 举报
回复
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=PageNo

在最前边加上一个PageNo = trim(PageNo)试试有提示吗?
一般情况下Recordset1.AbsolutePage的值只要是大于等于1,小于Recordset1.PageCount的数字就行,我以前碰到过类似的提示,主要是PageNo(当前页数)的值不正确,或者不是数字,或者为空,所以只要保证在absolutepage赋值之前,PageNo能过各种判断,保证是数字就应该没问题了
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 number123456 的回复:]
在这行Recordset1.AbsolutePage=cint(PageNo)之前
Response.write PageNo
看看是什么?
[/Quote]


取消Recordset1.AbsolutePage= PageNo此行内容,网页显示正常,测试response.write PageNo %>输出值是:
假如有2页,点击时,<% response.write PageNo %>输出值是2,假如有3页,<% response.write PageNo %>输出值是3,以此类推,并能显示分页码1、2、3。。。。


测试结果如下:红字为<%response.write PageNo %>输出结果:

1  当前页: 第1页[共3页]  共5条 [下一页] 第1、2、3页 [上一页]
number123456 2009-09-01
  • 打赏
  • 举报
回复
在这行Recordset1.AbsolutePage=cint(PageNo)之前
Response.write PageNo
看看是什么?
brdiy 2009-09-01
  • 打赏
  • 举报
回复
谢谢啊 ~~~~~~~~~~~~~··
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 chinabh 的回复:]
给你找了个高效的分页例子,几十万分页只需要几十毫秒
http://www.bhcode.net/code/11979.html
[/Quote]

老兄,不能下载呀
chinabh 2009-09-01
  • 打赏
  • 举报
回复
给你找了个高效的分页例子,几十万分页只需要几十毫秒
http://www.bhcode.net/code/11979.html
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 g125989100 的回复:]
PageNo = request("PageNo")
if not isnumeric(PageNo ) or PageNo = "" then
    PageNo = 1
else
    PageNo = clng(PageNo)
end if
if PageNo <1 then
    PageNo = 1
elseif PageNo >Recordset1.PageCount then
    PageNo = Recordset1.PageCount
end if
Recordset1.AbsolutePage = PageNo

[/Quote]



已试过,不行。Recordset1.AbsolutePage=PageNo提示参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
不耐烦 2009-09-01
  • 打赏
  • 举报
回复
PageNo = request("PageNo")
if not isnumeric(PageNo ) or PageNo = "" then
PageNo = 1
else
PageNo = clng(PageNo)
end if
if PageNo <1 then
PageNo = 1
elseif PageNo >Recordset1.PageCount then
PageNo = Recordset1.PageCount
end if
Recordset1.AbsolutePage = PageNo
szlx169 2009-09-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 g125989100 的回复:]
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=cint(PageNo)
[/Quote]


已试过,不行。Recordset1.AbsolutePage=cint(PageNo)提示参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
szlx169 2009-09-01
  • 打赏
  • 举报
回复
参数传递不成功
PageNo=CInt(Request("PageNo"))
在这句之前先判断Request("PageNo")是否为空


怎么判断?网页代码下页不是有判断
不耐烦 2009-09-01
  • 打赏
  • 举报
回复
if PageNo = "" or Isnull(PageNo) then PageNo = 1
if not Isnumeric(PageNo) then PageNo = 1
if PageNo < 1 then PageNo = 1
if ccur(PageNo)>ccur(Recordset1.PageCount) then PageNo = Recordset1.PageCount
Recordset1.AbsolutePage=cint(PageNo)
加载更多回复(10)

28,391

社区成员

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

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