各位高手,怎样对存储过程返回的纪录集分页(用pagecount,absolutepage)

jovizsb 2003-12-22 03:28:59
希望能得到真实实现的代码,原理就不需要了
看了网上很多介绍的,但实际用上的时候都不太正常
愿意高分祈求。
(从建立了结开始,到获得纪录集,希望纪录集的rs.recordcount,rs.pagecount能够反应真实的记录数目)
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jovizsb 2003-12-23
  • 打赏
  • 举报
回复
谢谢各位online(龙卷风(白学了,重新充电中)) ,capcom(大浪淘沙),one_wang(yOooo) ,问题解决了,是我参数设置错误了。

one_wang 2003-12-23
  • 打赏
  • 举报
回复
无论是sql语句还是SP(Stored Procedure)最后返回都是记录集(RecordSet),如果你不是在SP里实现分页,那也就没有什么不同
jovizsb 2003-12-22
  • 打赏
  • 举报
回复
to capcom(大浪淘沙)
sql="select * from sz_speak"
有没有
sql=存储过程
的实现情况呢
jovizsb 2003-12-22
  • 打赏
  • 举报
回复
谢谢两位,刚来这个潭,不知道怎么给两位加分,
非常谢谢
capcom 2003-12-22
  • 打赏
  • 举报
回复
注意修改文件名就好了!本文件的文件名为“admin.asp”
capcom 2003-12-22
  • 打赏
  • 举报
回复
可以实现分页的!!直接COPY就可以了!

<% @ language="vbscript" %>
<!--#Include file="ADOVBS.inc"-->
<html>
<head>
<title>admini</title>

</head>
<body>
<%
const MaxPerPage=5
dim totalPut
dim CurrentPage
dim TotalPage
dim i,j
if not isempty(request("Page")) then
currentPage=cint(request("Page"))
else
currentPage=1
end if
set conn=Server.CreateObject("ADODB.connection")
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from sz_speak"
conn.open "dsn=student;uid=sa;pwd=sa"
rs.open sql,conn,1,1
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if(currentpage-1)*Maxpege>totalput then
if(totalPut mod MaxPerPage)=0 then
currentpage=totalPut\ MaxPerPage
else
currentpage=totalPut\MaxPerPage+1
end if
end if
if currentpage=1 then
showpage totalput,MaxPerPage,"admini.asp"
showContent
showpage totalput,MaxPerPage,"admini.asp"
else
if(currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"admini.asp"
showContent
showpage totalput,MaxPerPage,"admini.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"admini.asp"
showContent
showpage totalput,MaxPerPage,"admini.asp"
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
%>
<form method="post" action="del.asp">
<div align="justify">
<p align="center"><i><b><font face="Arial, Helvetica, sans-serif" size="2" color="#808080"></font></b></i></p>
<%do while not rs.eof%>
<table border="0" width="502" height="13" bgcolor="#FFFFFF" align="center">
<tr bgcolor="#B4ECF8">
<td width="38" height="18">
<table width="35" border="0" cellspacing="0" cellpadding="0" name="table">
<tr>
<td width="35">
<input type="checkbox" name="checkbox" value= "<% =rs("id") %>" >
<p>
</td>
</tr>
</table>
</td>
<td width="454" height="18">
<%
response.write"ÁôÑÔÕßÐÕÃû£º"&rs("name")&""
response.write"ÁôÑÔʱ¼ä£º"&rs("logtime")&"<BR>"
response.write"ÁôÑÔÖ÷Ì⣺"&rs("topic")&"<BR>"
response.write"ÁôÑÔÄÚÈÝ£º"&rs("content")&"<BR>"
%>
</td>
</tr>
</table>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop %>
<p align="center"> <font face="»ªÎÄÐп¬">
<input type="submit" name="Submit" value="ɾ³ý">
<input type="reset" name="reset" value="ÖØÖÃ">
<input name="Submit2" type="submit" onClick="window.open('showpp.asp','','width=200,height=200')" value="ÏÔʾ" >
</font> </div>
</form>

<%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&" name=aaa>"
response.write"<p align='center'>>>·ÖÒ³ "
if CurrentPage<2 then
response.write"<font color='9999966'>Ê×Ò³ ÉÏÒ»Ò³</font> "
else
response.write"<a href="&filename&"?page=1&>Ê×Ò³</a> "
response.write"<a href="&filename&"?page="¤tPage-1&">ÉÏÒ»Ò³</a> "
end if
if n-currentpage<1 then
response.write"<font color='999966'>ÏÂÒ»Ò³ βҳ</font>"
else
response.write"<a href="&filename&"?page="¤tPage+1&">ÏÂÒ»Ò³</a> "
response.write"<a href="&filename&"?page="&n&">βҳ</a>;"
end if
response.write"Ò³´Î <strong><font color=red>"¤tPage&"</font>/"&n&"</strong>Ò³"
response.write"תµ½:<input type='text' name='page' size=4 maxlength =10 class=smallInput value="¤tpage&" >"
response.write"<input class=buttonface type='submit' value='Goto' name='cndok' ></span></p></form>"
end function
%>
</body>
</html>
online 2003-12-22
  • 打赏
  • 举报
回复
以前写的,没有问题
<%
dim oconn,strsql,table,rsresult,objcmdcount,strparameter1,strparameter2
myself=request.servervariables("script_name")
set oconn=server.createobject("adodb.connection")
oconn.open application("strconn")

set rsresult=server.createobject("adodb.recordset")
rsresult.cursorlocation=aduseclient '游标的位置
rsresult.cursortype=adopenstatic '游标的类型
rsresult.CacheSize =20
set rsresult.activeconnection=oconn
%>
'jjszb是存储过程的名字
'没有使用command对象
strsql = " jjszb '"& strparameter1 & "','" & strparameter2 & "','" & mode & "','" & bldddm & "','" & dwlxdm & "'"
rsresult.open strsql,oconn,3,adcmdtext
if rsresult.bof and rsresult.eof then
response.write "在数据库中没有找到指定的纪录,请查询"
response.end
end if

%>
<%
rsresult.PageSize =20
Page= CLng(Request.QueryString ("Page"))
If Page < 1 Then Page = 1
If Page > rsresult.PageCount Then Page = rsresult.PageCount
if searchtype="1" then
Response.Write "<CENTER><TABLE BORDER=1 cellspacing=0 cellpadding=2 width=1300>"
Response.Write "<TR BGCOLOR=silver align=center>"
Response.WRITE "<TD nowrap>当前记录</TD>"
response.write"<td width=200 nowrap>单位名称</td>"
response.write"<td nowrap>缴费单位数</td>"
response.write"<td nowrap>缴费人数</a></td>"
response.write"<td nowrap>人均基数</a></td>"
response.write"<td nowrap>本月实际征缴额</a></td>"
response.write"<td nowrap>本期实际征缴额</a></td>"
response.write"<td nowrap>离退休单位数</a></td>"
response.write"<td nowrap>离退休人数</a></td>"
response.write"<td nowrap>人均养老金</a></td>"
response.write"<td nowrap>本月实支养老金</a></td>"
response.write"<td nowrap>本期实支养老金</a></td>"
response.write"<td nowrap>本月实际收支差</a></td>"
response.write"<td nowrap>本期实际收支差</a></td>"
response.write"</tr>"

Response.Write "<TR align=center>"
Response.Write "<td> </td>"
Response.Write "<td> </td>"
for i=1 to rsresult.fields.count-2
Response.Write "<td>"&i&"</td>"
next
Response.Write "</tr>"

response.Write "<TR align=right>"
Response.Write "<td> </td>"
Response.Write "<td align=left>合计</td>"
for i=0 to objcmdcount.fields.count-1
Response.Write "<td>"&objcmdcount.fields.item(i)&"</td>"
next
rsresult.AbsolutePage = Page
For iPage = 1 To rsresult.PageSize
row="<tr align=right>"
RecNo = (Page - 1) * rsresult.PageSize + iPage
Response.Write row&"<TD>" & RecNo & "</TD>"
response.write "<td align=left rowrap><a href='jjszbdz.asp?s1="&strparameter1&"&s2="&strparameter2&"&s3="&searchtype&"&bldd=0&dwlx="&rsresult("dwlxdm")&"'>"&rsresult("dwlx")&"</a></td>"
For i=2 to rsresult.Fields.Count-1
response.write "<TD>" & rsresult(i) & "</TD>"
Next
Response.Write "</TR>"
rsresult.MoveNext
If rsresult.EOF Then Exit For
next
Response.Write "</TABLE></CENTER>"
end if
%>

<DIV ALIGN=right><P>
<HR width=100%>
<form name="form1" method="get" language="javascript">
<%If Page <> 1 Then%>
<A HREF="<%=myself%>?Page=1&s1=<%=strparameter1%>&s2=<%=strparameter2%>&s3=<%=searchtype%>">第一页</A>
<A HREF="<%=myself%>?Page=<%=(Page-1)%>&s1=<%=strparameter1%>&s2=<%=strparameter2%>&s3=<%=searchtype%>"'>上一页</A>
<%End If%>
<%If Page <> rsresult.PageCount Then%>
<A HREF="<%=Myself%>?Page=<%=(Page+1)%>&s1=<%=strparameter1%>&s2=<%=strparameter2%>&s3=<%=searchtype%>">下一页</A>
<A HREF="<%=Myself%>?Page=<%=rsresult.PageCount%>&s1=<%=strparameter1%>&s2=<%=strparameter2%>&s3=<%=searchtype%>">最后的一页</A>
<%End If%>
页次:<FONT COLOR="Red"><%=Page%>/<%=rsresult.PageCount%></FONT>
</FORM>
</P></DIV>
<%
rsresult.close
objcmdcount.close
oconn.Close
set rsresult=nothing
set objcmdcount=nothing
set oconn=nothing
%>

28,407

社区成员

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

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