asp下實(shí)現(xiàn)記錄集內(nèi)隨機(jī)取記錄的代碼
更新時(shí)間:2007年11月24日 22:09:07 作者:
記錄集內(nèi)隨機(jī)取記錄的代碼
<%
' 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
%>
<%
' 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
%>
相關(guān)文章
asp下實(shí)現(xiàn)字符串的補(bǔ)充fill()
在一個(gè)字符串前后補(bǔ)全另一字符串,在一個(gè)字符串前面補(bǔ)全另一字符串,在一個(gè)字符串后面補(bǔ)全另一字符串2008-02-02
使用FSO修改文件夾的名稱實(shí)現(xiàn)文件轉(zhuǎn)移防盜鏈
2008-01-01
asp中通過getrows實(shí)現(xiàn)數(shù)據(jù)庫(kù)記錄分頁(yè)的一段代碼
asp中通過getrows實(shí)現(xiàn)數(shù)據(jù)庫(kù)記錄分頁(yè)的一段代碼...2006-09-09
asp 讀取通過表單發(fā)送的post數(shù)據(jù)
學(xué)習(xí)ASP,最重要的就是要掌握ASP內(nèi)置的六大對(duì)象,如果以前沒接觸過,聰明的您就不要管這些概念了,知道怎么用就行了,我的觀點(diǎn)是剛開始關(guān)鍵在于臨摹2012-12-12
ASP中Session技巧 默認(rèn)過期時(shí)間為20分鐘
寫過稍微大型一點(diǎn) ASP 的人都知道,Session 這個(gè)對(duì)象真是好用,它可以用來記錄使用者私有的資料變量,既安全又方便。但是你真的知道 Session 的運(yùn)作原理嗎?2012-08-08
asp中提示至少一個(gè)參數(shù)沒有被指定值 解決方法
在寫SQL語句的時(shí)候,我們經(jīng)常會(huì)調(diào)用一些參數(shù),很可能這些參數(shù)中有一個(gè)沒有被賦值2012-10-10

