与你们不一样的分页????????
刚学习到分页。。
我的老师说现在的分页是直接的使用sql语句。象下面的
select top 10 * from orders
where orderid not in
(
select top 10 orderid from orders
order by orderid
)
order by orderid
我在论坛里看了很多分页,都是用的"select * from tab" ,我觉得这样的效率很低。
我想请教大家,我说的方法怎么使用了 如何在asp里掉用,??????
问题点数:20、回复次数:14Top
1 楼zhuowei(I'm MS MVP)回复于 2005-08-01 15:49:54 得分 0
这样就可以分页了吗?
我还不知道
select top 10 * 我用过N多次了
但没想过他还能分页啊``
哈哈 学习 等带别人过来解释一下``Top
2 楼litterrose(美眉)回复于 2005-08-01 15:50:53 得分 0
没有人回答呀。。
谁知道呀,55555
email guiter20002001@yahoo.com.cn 谁有例题,给我一个。。Top
3 楼wsyqit(wind)回复于 2005-08-01 16:03:32 得分 0
我在一个项目中用的分页sql如下(效果很好的):
sqlstr="select top "&PageSize&" * from tbl_product where 1=1 "& sqlwhere & " and (p_id not in(select top "&(PageSize*(current_page - 1))&" p_id from tbl_product where 1=1 "& sqlwhere & orderby &"))" &orderby
Top
4 楼syre(神仙)回复于 2005-08-01 16:04:47 得分 0
还有更好的方案
access,sqlserver没有limit麻烦多了Top
5 楼litterrose(美眉)回复于 2005-08-01 16:17:01 得分 0
不好意思。
我 是说的 asp + access ,各位有没有具体点的例题,给个详细点的好吗?Top
6 楼litterrose(美眉)回复于 2005-08-01 16:38:34 得分 0
有人没有呀。。Top
7 楼proclsj999(程序思想)回复于 2005-08-01 17:43:14 得分 0
pagesize;pagecount;absolutepage;这三个加起来用,,不是一样吗??学习中Top
8 楼yuliang0828(殷剑平)回复于 2005-08-01 19:36:34 得分 0
我理解楼主的分页方法只适用于2页的。他如何能判断当前页的记录集从哪里开始呢?无非是排除了前10个记录的后十个记录。如果稍加修改应该还是可行的。Top
9 楼剑锋冷月(时间可以倒留)回复于 2005-08-01 19:51:02 得分 0
http://community.csdn.net/Expert/topic/3991/3991936.xml?temp=.3752558Top
10 楼FEB15(张郎)回复于 2005-08-01 20:10:36 得分 0
UpTop
11 楼holoon(大家好才是真的好)回复于 2005-08-01 20:46:28 得分 0
<%
dim conn,dbss
dbss="#lybdate.mdb"
'========================建立数据库连接(开始)====
set conn=server.createObject("ADODB.Connection")
'conn.connectiontimeout=100
'on error resume next
conn.open "provider=MICROSOFT.JET.oledb.4.0;data source=" & server.mappath(dbss)
'conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath(dbss)
'========================建立数据库连接(结束)====
%>
<%
dim iPageSize,CurrentPage,rno,rc
iPageSize=5
CurrentPage=trim(request("CurrentPage"))
if CurrentPage<>"" then
If not isNumeric(CurrentPage) then '判断CurrentPage的值是否为数字类型
response.write "非法参数!"
response.End()
end if
end if
if CurrentPage="" then CurrentPage=1 end if
if currentpage<1 then currentpage=1 end if
'=====================循环显示记录(开始)===================
set rs=server.createobject("adodb.recordset")
if CurrentPage=1 then
Sql = "Select Top "& iPageSize &" * from lybs order by id desc"
else
Sql = "Select Top "& iPageSize &" * from lybs where id not in(Select Top "& iPageSize*(CurrentPage-1) &" id from lybs order by id desc) order by id desc"
end if
rs.open sql,conn,1,1
rc=rs.recordcount
if not rs.eof then
while NOT rs.EOF
response.write "(<font color=blue>id:</font><font color=red>"&rs("id")&"</font>) 姓名:" & rs("username") & "<br><br>"
rs.movenext
wend
else
response.write "no record"
end if
rs.close '关闭记录集
set rs=nothing '清空记录集
'=====================循环显示记录(结束)===================
%>
<br><br>
<a href="?CurrentPage=<%=CurrentPage-1%>">上页</a>
<%
if rc>=iPageSize then
CurrentPage=CurrentPage+1
else
CurrentPage=CurrentPage
end if
%>
<a href="?CurrentPage=<%=CurrentPage%>">下页</a>
有兴趣的朋友,可以去下源文件来看看。
http://www.it971.com/fy/fy.rarTop
12 楼litterrose(美眉)回复于 2005-08-02 08:55:25 得分 0
to :holoon(迷途的小菜鸟)
谢谢你的回答,可是你说的这个连接,我打不开呀。不知道是怎么回事情。。Top
13 楼patchclass(黑翼)回复于 2005-08-02 09:07:31 得分 0
去拿个存储过程的分页看看
select * from 分页是用
absolutePage属性的,的确效率是低点,不过小数据量下还可以接受Top
14 楼litterrose(美眉)回复于 2005-08-02 10:06:15 得分 0
搞定了,看了你说的那个网站,我觉得这个网站很好也。大家也去看看。。Top




