高端网站建设-记录集内随机取记录的代码
author:一佰互联 2019-04-15   click:233
 <% 

" 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

%>

 

高端网站建设价格套餐:

500元成品模板网站套餐1000元基础型网站套餐1800元标准定制设计套餐2800元精美定制设计套餐3800-8000元商务型套餐行业门户型套餐其它定制套餐 文章由重庆一佰互联高端网站建设http://www.yinxi.net编辑整理,转载请注明出处