菜鸟提问(分页问题)

xjl999 2003-07-29 02:43:32
小弟刚刚看看有关asp有关分页的内容
看得有点糊涂,好象recordset有几个像pagesize和absulotepage属性来实现分页
我的后台数据库是oracle的,是不是不能用这些属性啊?
还有,是不是不用这些属性也可以实现分页啊?
请哪位高手详细概括地说明一下分页的几种技术,以及它们针对各种后台数据库有没有什么不同,谢谢了!!
...全文
45 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhonggan 2003-07-29
  • 打赏
  • 举报
回复
数据库不同只是改连接串就可以了,和代码没有关系的
我也给一个分页的代码~
<%
page=Request("page")'当前页
if page=0 or page="" then
page=1
end if

'取得记录数
RecordCount = 0
do while not rs.Eof
RecordCount = RecordCount +1
rs.MoveNext
loop
if not RecordCount=0 then
rs.MoveFirst
end if

'取得总页数

pageCount=RecordCount/10
pageCount=int(pageCount) if (RecordCount mod 10)>0 then
PageCount=PageCount +1
end if
%>


<% if not rs.eof then
rs.movefirst

'将记录取到当前页
do while pos<(page-1)*10
pos=pos+1
rs.MoveNext
loop

i=0
x=0
'显示记录每页10条(x)
do while x<10 and not rs.eof %>

<tr><td><%'记录字段%></td></tr>

<% i=i+1
x=x+1
rs.movenext
loop
rs.close
end if
%>

<%
'列出页码
response.write "页码:"
y=1
do while y<pagecount+1
response.write "<a href='页.asp?page=" &y& "'>["&y&"]</a>"
y=y+1
loop%>

xjl999 2003-07-29
  • 打赏
  • 举报
回复
再请高手看看!!
zhuxiaong 2003-07-29
  • 打赏
  • 举报
回复
pagesize:一页的在记录大小
absulotepage:换页时,指针指到每一页的第一条记录
PageCount:按之前提供的pagesize分页规则,所有记录应该分几页
如:
RS.AbsolutePage=session("currentpage")'当前是哪一页
pagesize=20 每页显示二十个记录
PageCount 总共多少页
dicklee1214 2003-07-29
  • 打赏
  • 举报
回复
对数据库没有特殊要求
xjl999 2003-07-29
  • 打赏
  • 举报
回复
对于oracle数据库也可以使用上述的属性吗?
dicklee1214 2003-07-29
  • 打赏
  • 举报
回复
<%
PgSz=10
Set Conn=Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")
conn.Open"dsn=business;uid=businessuser;pwd=businessuser"
strsql="select a.*,b.mean from balancewastebook a,balancetype b where a.memberid="
strsql=strsql&session("memberid")&" and a.relationmanid="&session("relationmanid")
strsql=strsql&" and a.balancewastebookid=b.balancewastebookid"
RS.open strsql,Conn,1,1
If RS.RecordCount=0 then
response.write "<P><center>对不起,数据库中没有相关信息!</center></P>"
else
RS.PageSize = Cint(PgSz)
Total=INT(RS.recordcount / PgSz * -1)*-1
PageNo=Request("pageno")
if PageNo="" Then
PageNo=1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction=Request("ScrollAction")
if ScrollAction="上一页" Then
PageNo=PageNo-1
end if
if ScrollAction="下一页" Then
PageNo=PageNo+1
end if
if PageNo<1 Then
PageNo=1
end if
n=1
RS.AbsolutePage = PageNo
'Response.Write "<CENTER>"
position=RS.PageSize*PageNo
pagebegin=position-RS.PageSize+1
if position<RS.RecordCount then
pagend=position
else
pagend= RS.RecordCount
end if
'Response.Write "<P><font color='Navy' size=2><B>数据库查询结果:</B>"
Response.Write "<br><P><font color='Navy' size=2>(共有"&RS.RecordCount &"条符合条件的信息,显示"&pagebegin&"-"&pagend&")</font></p>"
%>
</div>
<TABLE WIDTH="64%" BORDER=1 align="center" CELLPADDING=2 CELLSPACING=0 BGCOLOR=#FFFFFF class="unnamed3">
<TR BGCOLOR=336699> <FONT SIZE=2>
<td width="18%" height="23" align="center"><font color="#FFFFFF">余额</font></td>
<td width="18%" align="center"><font color="#FFFFFF">服务费用</font></td>
<td width="18%" align="center"><font color="#FFFFFF">充值金额</font></td>
<td width="23%" align="center"><font color="#FFFFFF">余额类别</font></td>
<td width="23%" align="center"><font color="#FFFFFF">发生时间</font></td>
</FONT> </TR BGCOLOR=#FFFFFF>
<%
Do while not (RS is nothing)
RowCount=RS.PageSize
Do While Not RS.EOF and rowcount>0
If n=1 then
Response.Write "<TR BGCOLOR=#FFFFFF>"
ELSE
Response.Write "<TR BGCOLOR=#EEEEEE>"
End If
n=1-n
%>
<td width="18%" align="center"><%=rs("balance")%> </td>
<td width="18%" align="center"><%=rs("servicemoney")%> </td>
<td width="18%" align="center"><%=rs("fillmoney")%> </td>
<td width="23%" align="center"><%=rs("mean")%> </td>
<td width="23%" align="center"><%=rs("happenTime")%> </td>
<%
RowCount=RowCount-1
RS.MoveNext
Loop
set RS=RS.NextRecordSet
Loop
%>
</table>

<FORM METHOD=post action="--WEBBOT-SELF--">
<INPUT TYPE="HIDDEN" NAME="pageno" VALUE="<%=PageNo%>">
<%
if PageNo>1 Then
response.write "<INPUT TYPE=SUBMIT NAME=ScrollAction VALUE=上一页>"
end if
if RowCount=0 and PageNo<>Total then
response.write "<INPUT TYPE=SUBMIT NAME=ScrollAction VALUE=下一页>"
end if
response.write "<input type=button value=返回 name=B2 onclick=javascript:history.go(-1)>"
response.write "</FORM>"
End if
Conn.Close
set rs=nothing
set Conn=nothing
%>
</div>
danjingwu 2003-07-29
  • 打赏
  • 举报
回复
pagesize:一页要放几条记录
absulotepage:翻页时,指针指到每一页的第一条记录
PageCount:按之前提供的pagesize分页规则,所有记录应该分几页
recordcount(好象是这样写吧?我忘记了):总共有多少条记录数

好象各个数据库都没有多大的分别,说的不对,请高手指正
xjl999 2003-07-29
  • 打赏
  • 举报
回复
我不需要原代码,我想要一些技术说明,以及是不是有特定的数据库对应特定的数据库
xuya 2003-07-29
  • 打赏
  • 举报
回复
example:
<%

Sub TurnPage(ByRef 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>
<td width=95>转到第
<%If TotalPage = 1 Then%>
<input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%>
<input type=text name=PageNo size=3 value="" title=请输入页号,然后回车>
<%End If%>页
</td>
</tr>
</table>
<%End Sub%>

<%
dim str1
dim select_count
dim select_pagecount
Response.Expires =-9999
%>
<html>
<head>
<title>公共通讯录显示</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="oaoffice.css">
</head>
<body bgcolor="#5badff" text="#000000">
<table width="90%" border="0" cellspacing="0" cellpadding="0" align=right>
<TBODY>
<tr>
<td width="79%" bgcolor="#5badff">
<form name="form1" action="O_Pubaddrl.asp" method="post" >
<%

sql = "select fPubadrNo,FpubAdrCName,FpubAdrEname,Funitname from O_PubAddr"
if searchstr<>"" then
str1 = " where fpubadrno = '"& trim(searchstr) & "'"
sql = sql + str1
end if
set conn=server.createobject("ADODB.Connection")
conn.Open Application("dsn")
set rs = server.CreateObject ("adodb.recordset")
rs.open sql,conn,1,3

Dim RowCount
RowCount = 10 '每页显示的记录条数
Call TurnPage(Rs,RowCount) '公共翻页模块结束
if rs.EOF then
rs.Close
set rs=nothing
conn.Close
set conn=nothing
Response.Write "没有符合条件的记录"
Response.Write "</body></html>"
Response.End
end if

%>


<DIV></DIV>
<DIV align=center>

<TABLE borderColor=#c0c0c0 cellSpacing=0 cellPadding=0 width="100%" border=1>

<TR>
<TD align=middle width="10%" bgColor=#c0c0c0>编号</TD>
<TD align=middle width="10%" bgColor=#c0c0c0>中文姓名</TD>
<TD align=middle width="15%" bgColor=#c0c0c0>英文姓名</TD>
<TD align=middle width="20%" bgColor=#c0c0c0>单位</TD>
</TR>

<%
If Not Rs.eof then
Do while Not rs.eof and RowCount>0
%>
<TR>
<TD align=middle width="10%">
<P align=left><INPUT style="LEFT: 32px; TOP: 0px" type=checkbox id=checkbox1 name=checkbox1 value= 1 > <%=rs("fPubadrNo")%> </P></TD>
<TD align=middle width="10%"><P align=left><%=rs("fPubadrcname")%> </P></TD>
<TD align=middle width="15%"><P align=left><%=rs("fPubadreName")%> </P></TD>
<TD align=middle width="20%"><P align=left><%=rs("funitname")%> </P></TD>
</TR>
<%
RowCount = RowCount - 1
Rs.MoveNext
Loop
End If
rs.Close
conn.Close
%>
</TABLE></DIV>
<DIV align=center><INPUT type=submit value=Submit>  <INPUT
size=3 name=searchstr >
<table>
<DIV></DIV>
</form>
</td>
</tr>
</table></DIV></TD></TR></TBODY></TABLE>
</body>
</html>

28,391

社区成员

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

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