asp下实现记录集内随机取记录的代码

所属分类: 网络编程 / ASP编程 阅读数: 1002
收藏 0 赞 0 分享
记录集内随机取记录的代码

<% 
' 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中去除内容HTML标签的三个function函数

asp中去除内容HTML标签的三个function函数
收藏 0 赞 0 分享

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解
收藏 0 赞 0 分享

方便的大家admin及admin888 经过 md5加密后16位和32位代码

方便的大家admin及admin888 经过 md5加密后16位和32位代码
收藏 0 赞 0 分享

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
收藏 0 赞 0 分享

asp动态级联菜单代码

asp动态级联菜单代码
收藏 0 赞 0 分享

ASP中经常使用的SQL语句与教程说明

ASP中经常使用的SQL语句与教程说明
收藏 0 赞 0 分享

实例分析之用ASP编程实现网络内容快速查找的代码

实例分析之用ASP编程实现网络内容快速查找的代码
收藏 0 赞 0 分享

服务端 VBScript 与 JScript 几个相同特性的写法与示例

服务端 VBScript 与 JScript 几个相同特性的写法与示例
收藏 0 赞 0 分享

ASP 环境下 VBS 事件应用 示例代码

ASP 环境下 VBS 事件应用 示例代码
收藏 0 赞 0 分享

asp 之上传漏洞终结篇

asp 之上传漏洞终结篇
收藏 0 赞 0 分享
查看更多