Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > asp技巧

asp下实现记录集内随机取记录的代码

来源:中文源码网    浏览:192 次    日期:2024-05-16 04:41:39
【下载文档:  asp下实现记录集内随机取记录的代码.txt 】


asp下实现记录集内随机取记录的代码
记录集内随机取记录的代码 <% ' 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 %>

相关内容