asp下实现记录集内随机取记录的代码
程序员文章站
2022-05-18 11:42:26
记录集内随机取记录的代码 <% ' moving to random record - ste...
记录集内随机取记录的代码
<%
' moving to random record - steven jones' extension
if not(记录集名称.bof and 记录集名称.eof) then
' reset the cursor to the beginning
if (记录集名称.cursortype > 0) then
记录集名称.movefirst
else
记录集名称.requery
end if
记录集名称_totalrn = -1
记录集名称_totalrn = 记录集名称.recordcount ' ony works on some recordsets, but much faster
if (记录集名称_totalrn = -1) then ' and if it didn't work, we still have to count the records.
' count the total records by iterating through the recordset
记录集名称_totalrn=0
while (not 记录集名称.eof)
记录集名称_totalrn = 记录集名称_totalrn + 1
记录集名称.movenext
wend
' reset the cursor to the beginning
if (记录集名称.cursortype > 0) then
记录集名称.movefirst
else
记录集名称.requery
end if
end if
' now do final adjustments, and move to the random record
记录集名称_totalrn = 记录集名称_totalrn - 1
if 记录集名称_totalrn > 0 then
randomize
记录集名称.move int((记录集名称_totalrn + 1) * rnd)
end if
end if
' all done; you should always check for an empty recordset before displaying data
%>
<%
' moving to random record - steven jones' extension
if not(记录集名称.bof and 记录集名称.eof) then
' reset the cursor to the beginning
if (记录集名称.cursortype > 0) then
记录集名称.movefirst
else
记录集名称.requery
end if
记录集名称_totalrn = -1
记录集名称_totalrn = 记录集名称.recordcount ' ony works on some recordsets, but much faster
if (记录集名称_totalrn = -1) then ' and if it didn't work, we still have to count the records.
' count the total records by iterating through the recordset
记录集名称_totalrn=0
while (not 记录集名称.eof)
记录集名称_totalrn = 记录集名称_totalrn + 1
记录集名称.movenext
wend
' reset the cursor to the beginning
if (记录集名称.cursortype > 0) then
记录集名称.movefirst
else
记录集名称.requery
end if
end if
' now do final adjustments, and move to the random record
记录集名称_totalrn = 记录集名称_totalrn - 1
if 记录集名称_totalrn > 0 then
randomize
记录集名称.move int((记录集名称_totalrn + 1) * rnd)
end if
end if
' all done; you should always check for an empty recordset before displaying data
%>
上一篇: 明朝的历史评价为何褒贬不一?大明王朝究竟是怎样的?
下一篇: 一个实用的FSO-实时统计在线人数
推荐阅读
-
可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
-
asp下实现记录集内随机取记录的代码
-
asp下sql和access数据库随机取10条记录的代码newid()
-
记录集内随机取记录的代码
-
ASP.NET 2.0下随机读取Access记录的实现方法
-
asp下sql和access数据库随机取10条记录的代码newid()
-
asp下实现记录集内随机取记录的代码
-
记录集内随机取记录的代码
-
asp.net下使用jquery 的ajax+WebService+json 实现无刷新取后台值的实现代码_jquery
-
asp.net下使用jquery 的ajax+WebService+json 实现无刷新取后台值的实现代码_jquery