大卫科波菲尔英文版:求救:ASP里的语句不懂。帮忙解释下。

来源:百度文库 编辑:高考问答 时间:2024/05/01 21:50:46
<%
if request.querystring("page")="" then
page="1"
else
page=request.querystring("page")
end if
set rs=server.createobject("adodb.recordset")
if session("userno")="" then
sql="select id,title from vote where iswork=true and anonymity=true order by id desc"
else
sql="select id,title from vote where iswork=true order by id desc"
end if
rs.open sql,conn,1,1
if rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.Write("<tr align=center><td ><font color=red>目前没有投票项目</font></td></tr>")
response.end
end if
if not rs.eof then
rs.PageSize = 10
rs.AbsolutePage = clng(page)
if cstr(page)=cstr(rs.PageCount) and (rs.RecordCount mod rs.PageSize <> 0) then
recend=rs.RecordCount mod rs.PageSize
else
recend=rs.PageSize
end if
dim o
o=1
for i=1 to recend
%>

sql="select id,title from vote where iswork=true and anonymity=true order by id desc"
是什么意思呢? iswork? anonymity? by id dese?

rs.AbsolutePage = clng(page)
if cstr(page)=cstr(rs.PageCount) and (rs.RecordCount mod rs.PageSize <> 0) then
recend=rs.RecordCount mod rs.PageSize
else
recend=rs.PageSize

这些AbsolutePage clng(page) cstr(page) 等等 是什么意思呢贯穿起来?

谢谢!!!^_^ 希望能稍详细点告诉我!谢谢!
整段话又是什么意思呢?理解理解着就糊涂了~~

AbsolutePage
你在查询数据库的时候,要进行分页的。
每页多少项你自己定了
但是你想读取其中的第几页,就把值付给AbsolutePage.如,AbsolutePage=5表示你现在在看第五页里面的内容。
也可以这样认为,AbsolutePage表示当前页

clng(page)
这个表示把page这个进行格式化,只可以是整型的数,页数不可以为小数点吧。我相信没有人见过有3.5页的页数
所以用clng把数值转换成整型

cstr(page)
CStr 强制将结果表示为 String。

sql="select id,title from vote where iswork=true and anonymity=true order by id desc"
是什么意思呢? iswork? anonymity? by id dese?
在你的数据库中iswork只有true和false两个选项,你就是把库中所以iswork是true的都查询出来

anonymity同理

order是一个排序函数,order by id desc是以id做为降序进行排序

在表 vote 中取出 满足iswork=true 和anonymity=true 条件 的 id,title
并按照id降序排列

在表 vote 中取出 满足iswork=true 和anonymity=true 条件 的 id,title
并按照id降序排列