手机
当前位置:查字典教程网 >编程开发 >ASP教程 >记录集内随机取记录的代码
记录集内随机取记录的代码
摘要:0)Then记录集名称.MoveFirstElse记录集名称.RequeryEndIfEndIf'nowdofinaladjustments...

<%

' 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遍历服务器对象的代码

用VB生成DLL封装ASP连接数据库的代码

本人常用的分页代码

ASP采集入库生成本地文件的几个函数

一小偷类!!有兴趣的可以看看

asp FSO 读写文件本文件实现代码

ASP 微信公共平台接口实现代码

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

asp获取当前URL代码

精品推荐
分类导航