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

ASP
一个查ASP木马的小东东
eWebEditor:网站中的隐形炸弹
跨站脚本执行漏洞详解与防护
XSS测试语句大全
Mssql高级注入笔记II
在MsSql、Access两种数据库中插入记录后马上得到自动编号的ID值
asp存储过程使用大全
生成静态页大全[ASP/PHP/ASPX]
显示在线人数
ASP 类 Class入门
一个ACCESS数据库访问的类
ASP操作Excel技术总结
几个常用的ASP函数
如何编写一个ASP类
数组显示菜单效果
创建一个ASP通用分页类
利用Split函数进行多关键字检索
asp实现表格3列5行
一句话木马入侵EASYNEWS新闻管理系统
ASP编程实用20例

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


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