帮忙看一下,recordset的bookmark属性,在这段程序里是做什么用的?

QYworld 2002-03-09 08:41:40
加精
一下是动网文章管理里的分页部分,其他地方都明白了,就是bookmark在这里没搞明白什么用,好像去掉了那句也无所谓,是吗?

<anguage="vbscript"

dim conn

dim connstr

dim totalPut

dim CurrentPage

dim TotalPages

dim i,j

dim sql

dim rs

on error resume next

'打开数据库

connstr="DBQ="+server.mappath("book.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

set conn=server.createobject("ADODB.CONNECTION")

conn.open connstr

set rs=server.createobject("adodb.recordset")

'定义每页文章显示数

const MaxPerPage=18

if not isempty(request("page")) then

currentPage=cint(request("page"))

else

currentPage=1

end if

sql="select * from learning order by articleid desc"

Set rs= Server.CreateObject("ADODB.Recordset")

rs.open sql,conn,1,1

if rs.eof and rs.bof then

response.write "<p align='center'> 还 没 有 任 何 文 章</p>"

else

'数据库中文章数totalput

totalPut=rs.recordcount

if currentpage<1 then

currentpage=1

end if

'统计总页数currentpage

if (currentpage-1)*MaxPerPage>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,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

else

if (currentPage-1)*MaxPerPage<totalPut then

rs.move (currentPage-1)*MaxPerPage

dim bookmark

bookmark=rs.bookmark
'~~~~~~~~~~~就是这里了!!!!!!
showpage totalput,MaxPerPage,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

else

currentPage=1

showpage totalput,MaxPerPage,"index.asp"

showContent

showpage totalput,MaxPerPage,"index.asp"

end if

end if

rs.close

end if

set rs=nothing

conn.close

set conn=nothing

sub showContent

dim i

i=0

do while not rs.eof

>

'选择显示数据库内容

<a href="openarticle.asp?id=<=rs("articleid")>"><=rs("title")></a>[点击:<=rs("hits")>]<br>

<

'当显示记录大于maxperpage时结束这页

i=i+1

if i>=MaxPerPage then exit do

rs.movenext

loop

end sub

function showpage(totalnumber,maxperpage,filename)

'求出当每页18篇文章时总共的页数

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&">"

response.write "<p align='center'><font color='#000080'>>>分页</font> "

'显示页数链接的条件

if CurrentPage<2 then

response.write "<font color='#000080'>首页 上一页</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='#000080'>下一页 尾页</font>"

else

response.write "<a href="&filename&"?page="&(CurrentPage+1)

response.write ">下一页</a> <a href="&filename&"?page="&n&">尾页</a>"

end ifc

response.write "<font color='#000080'> 页次:</font><strong><font color=red>"¤tPage&"</font><font color='#000080'>/"&n&"</strong>页</font>"

response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font>"

response.write " <font color='#000080'>转到:</font><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

>
...全文
165 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
QYworld 2002-03-11
  • 打赏
  • 举报
回复
OK,多谢了
我自己做东西时,用用试试也就明白了
给分!
julyclyde 2002-03-11
  • 打赏
  • 举报
回复
自己定义变量来记录?你用什么特征可以唯一的确定一条记录?不要说ID!那是不可靠的

从上面的程序来看,那个bookmark没用
julyclyde 2002-03-10
  • 打赏
  • 举报
回复
bookmark就是书签嘛,用来move过后再找回来这条记录
QYworld 2002-03-10
  • 打赏
  • 举报
回复
笨的要死。。。还是有点不理解

干脆这么问吧,在上面那个分页程序,用了bookmark来记录原来的记录,有什么好处?

用了bookmark可以提高分页的效率?
QYworld 2002-03-10
  • 打赏
  • 举报
回复
呵呵,还是不理解

我去掉bookmark那句好像也不影响该程序

能不能打个比方?
Lostinet 2002-03-10
  • 打赏
  • 举报
回复
我没有用过那个东西。
自己定义变量来记录不好么?
julyclyde 2002-03-10
  • 打赏
  • 举报
回复
如果你用了move系列方法,就有可能找不到原来的记录了
用了bookmark就可以找到

不影响程序是因为程序不依赖啊,这还不明白?
zznn123 2002-03-10
  • 打赏
  • 举报
回复
提供记录或指向数据指针当前位置的功能
QYworld 2002-03-10
  • 打赏
  • 举报
回复
踢一下,帮忙
QYworld 2002-03-09
  • 打赏
  • 举报
回复
是画“~~~~~”标出的部分,帮忙看一下

虽然很长,其实需要看的只一部分

28,406

社区成员

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

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