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

ASP
浅谈 ASP 模板技术之参数传递
九种防MDB数据库被下载的方法
如何采集静态文章系统
提供几个关于采集的函数(ASP)
ASP小偷(远程数据获取)程序的入门教程
远程图片自动按文件夹上传到服务器-默飞出品
纯编码实现Access数据库的建立或压缩
同一个帐号不能同时登陆的问题
跨越fso、wsh、 application写文件
用ASP设计购物推车
ASP中Web页面间的数据传递方式
ASP得到文件的大小类型最后修改时间
截取实际长度字符串,并用空格替换
本人常用的分页代码
一句话木马连接客户端
编写网页木马详解
Asp生成HTML方法大全
利用xmlhttp和adodb.stream加缓存技术下载远程Web文件
用ASP实现远程批量文件改名
如何准确定时运行ASP文件

ASP 中的 记录集内随机取记录的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 95 ::
收藏到网摘: 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
%>