加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp下做成记录集内随机取记录的代码

发布时间:2023-05-27 12:54:03 所属栏目:Asp教程 来源:
导读:记录集内随机取记录的代码:<% &#39; Moving to random record - Steven Jones&#39; ExtensionIf Not(记录集名称.bof and 记录集名称.eof) Then&#39; reset the cursor to the beginningIf (记录集名称.CursorType >

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

<% 

' 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

%> 

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章