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

所属分类: 网络编程 / ASP编程 阅读数: 1640
收藏 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 指南

ASP 指南
收藏 0 赞 0 分享

改进 ASP 的字符串处理性能

改进 ASP 的字符串处理性能
收藏 0 赞 0 分享

pjblog2的参数第1/2页

pjblog2的参数
收藏 0 赞 0 分享

ASP智能搜索的实现

ASP智能搜索的实现
收藏 0 赞 0 分享

网站生成静态页面攻略2:数据采集

网站生成静态页面攻略2:数据采集
收藏 0 赞 0 分享

网站生成静态页面攻略3:防采集策略

网站生成静态页面攻略3:防采集策略
收藏 0 赞 0 分享

网站生成静态页面攻略4:防采集而不防搜索引擎策略

网站生成静态页面攻略4:防采集而不防搜索引擎策略
收藏 0 赞 0 分享

简单分页函数一 常用

简单分页函数一 常用
收藏 0 赞 0 分享

asp最常用的分页函数

asp最常用的分页函数
收藏 0 赞 0 分享

LINE9的目录浏览源程序

LINE9的目录浏览源程序
收藏 0 赞 0 分享
查看更多