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

殇3606

殇3606

2016-02-19 12:29

清醒时做事,糊涂时读书,大怒时睡觉,无聊时关注图老师为大家准备的精彩内容。下面为大家推荐记录集内随机取记录的代码,无聊中的都看过来。
%
' 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
%
展开更多 50%)
分享

猜你喜欢

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

Web开发
记录集内随机取记录的代码

在ASP中使用断开的记录集

ASP
在ASP中使用断开的记录集

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

ASP程序中使用断开的数据记录集

ASP
ASP程序中使用断开的数据记录集

一段返回随机记录的代码

ASP
一段返回随机记录的代码

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

在ASP中轻松实现记录集分页显示

ASP
在ASP中轻松实现记录集分页显示

一种基于记录集查找特定行的方法

SQLServer
一种基于记录集查找特定行的方法

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

显示数据库记录

显示数据库记录

截取实际长度字符串并用空格替换

截取实际长度字符串并用空格替换
下拉加载更多内容 ↓