asp下實現(xiàn)記錄集內(nèi)隨機取記錄的代碼
更新時間:2007年11月24日 22:09:07 作者:
記錄集內(nèi)隨機取記錄的代碼
<%
' 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偽靜態(tài)化方法及Asp靜態(tài)化探討
本站已經(jīng)收藏了不少關(guān)于偽靜態(tài)的文章,這篇文章本站已經(jīng)有了,但主要考慮比較詳細,大家可以參考下2008-08-08asp 防盜鏈代碼(徹底屏蔽迅雷,旋風(fēng),快車下載站內(nèi)資源)
asp 防盜鏈代碼(徹底屏蔽迅雷,旋風(fēng),快車下載站內(nèi)資源) ,判斷是不是下載工具下載,是則報404錯誤。2010-04-04asp飛飛無限級分類v1.0 Asp+sql+存儲過程+ajax提供下載
飛飛Asp樂園Asp Sql存儲過程版無限級分類 開發(fā)說明: 本程序基于Asp環(huán)境開發(fā) 使用的數(shù)據(jù)庫:SQLServer2000(存儲過程) js框架:Jquery/ajax 數(shù)據(jù)庫名稱:archives2008-03-03ASP 支持中文的len(),left(),right()的函數(shù)代碼
在用ASP處理文字時。系統(tǒng)自帶的字符串長度檢測函數(shù)有時候也不是很好用。2010-05-05