当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp下实现记录集内随机取记录的代码

ASP
ASP+XML实例演练编程代码
asp下利用XMLHTTP 从其他页面获取数据的代码
asp下实现IP限制函数代码
asp下IP地址分段计算函数
asp身份证验证代码函数
用Asp隐藏文件路径,实现防盗链 的代码
ASP生成柱型体,折线图,饼图源代码提供了
用asp实现网址和邮件地址的转换函数
asp下最简洁的多重查询的解决方案
asp下用datediff实现计算两个时间差的函数
asp下实现记录集内随机取记录的代码
asp下轻松实现将上传图片到数据库的代码
[原创]站长感慨asp编程究竟何去何从
fso asp生成静态html的代码
ASP版实现cookies注入加速工具
ASP实现网页打开任何类型文件都提示保存的方法附代码
asp下使用数组存放数据的代码
一句话 asp木马加密版 彻底突破杀毒软件
asp清空application的方法
使用asp下的adodb.stream 下载文件而不是打开

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 38 ::
收藏到网摘: n/a

记录集内随机取记录的代码
<%
' 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
%>