currentPage=trim(request.querystring("page"))
if isNumeric(currentPage) then
currentPage=cInt(currentPage)
if currentPage<1 then currentPage=1
else
currentPage=1
end if
sqlstr="select count(id) as totalRs from newsTopic"
set rs=conn.execute(sqlstr)
totalRs=rs("totalRs")
rs.close
totalPage=totalRs\pageSize+1
if currentPage>totalPage then currentPage=totalPage
headRs=pageSize * (currentPage-1)
sqlstr="select top " & pageSize & " id,topicName,working,setupTime from newsTopic where id not in(select top " & headRs & " id from newsTopic order by id desc) order by id desc"
set rs=conn.execute(sqlstr)
%>
select top 20 from ……,你不是说这个吧?嘻嘻,楼上这位同学你说到执行效率,但是你又知道select top 20 from ……这种语句执行效率又有多高呢?如果想不返回全部数据就可以用存储过程分页的方法,代码太长了不贴。其实huaxiaosxl (Ken Lee)你说的问题一样是用ado分页的方法来做的。比如RsInspect.AbsolutePage=5,你设置absolutepage的值就可以设置显示的页了。
dim pagenum
dim topnum
dim totalrec
pagenum=request.querystring("page")
if pagenum="" then pagenum=1
if not IsNumeric(pagenum) then pagenum=1
if pagenum=<0 then pagenum=1
if pagenum>99999 then pagenum=1
pagenum=fix(pagenum)
topnum=pagenum*20
sql="select top "&topnum&" ID,date,title from article where type="&ID
rs.open sql,arconn,1,1
totalrec=rs.recordcount
if (totalrec mod 20)=0 then
lastpage=totalrec\20
else
lastpage=totalrec\20+1
end if
if (pagenum-1)*20>=totalrec then
if (totalrec mod 20)=0 then
pagenum=totalrec\20
else
pagenum=totalrec\20+1
end if
end if
if not pagenum=1 and (pagenum-1)*20<totalrec then
rs.move (pagenum-1)*20
else
pagenum=1
end if