asp下实现记录集内随机取记录的代码
2007-11-24 22:09
736 查看
记录集内随机取记录的代码
<%
' 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
%>
相关文章推荐
- asp下实现记录集内随机取记录的代码
- ASP.NET 2.0下随机读取Access记录的实现方法
- ASP页面随机添加字符实现防复制的代码
- asp中实现随机分组程序的代码
- ASP页面随机添加字符实现防复制的代码
- asp.net 产生随机颜色实现代码
- asp.net gridview实现全选,反选与删除记录的操作代码
- 可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
- ASP 无重复数字随机函数, 数组实现, 并应用于随机显示记录集 By shawl.qiu
- asp中实现随机分组程序的代码
- 记录集内随机取记录的代码
- ASP实现:用一条SQL得到Access数据库中的随机记录集!
- asp中通过getrows实现数据库记录分页的一段代码
- asp下sql和access数据库随机取10条记录的代码newid()
- 记录游客页面访问IP的简易实现代码 (asp.net+txt)
- ASP.NET 2.0下随机读取Access记录的实现方法
- 记录集内随机取记录的代码
- asp.net gridview实现全选,反选与删除记录的操作代码