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 代碼出現(xiàn)80040e14錯(cuò)誤的解決方法
本文減淡概述了解決80040e14錯(cuò)誤的兩種方法。2009-04-04比較詳細(xì)的Asp偽靜態(tài)化方法及Asp靜態(tài)化探討
本站已經(jīng)收藏了不少關(guān)于偽靜態(tài)的文章,這篇文章本站已經(jīng)有了,但主要考慮比較詳細(xì),大家可以參考下2008-08-08asp 防盜鏈代碼(徹底屏蔽迅雷,旋風(fēng),快車下載站內(nèi)資源)
asp 防盜鏈代碼(徹底屏蔽迅雷,旋風(fēng),快車下載站內(nèi)資源) ,判斷是不是下載工具下載,是則報(bào)404錯(cuò)誤。2010-04-04asp生成不需要數(shù)據(jù)庫(kù)的中獎(jiǎng)碼
有一個(gè)思路是:將一批唯一中獎(jiǎng)碼,錄入的到數(shù)據(jù)庫(kù),中獎(jiǎng)時(shí),取出來(lái)一條,做一個(gè)標(biāo)記,把中獎(jiǎng)碼告訴2008-07-07asp飛飛無(wú)限級(jí)分類v1.0 Asp+sql+存儲(chǔ)過(guò)程+ajax提供下載
飛飛Asp樂(lè)園Asp Sql存儲(chǔ)過(guò)程版無(wú)限級(jí)分類 開發(fā)說(shuō)明: 本程序基于Asp環(huán)境開發(fā) 使用的數(shù)據(jù)庫(kù):SQLServer2000(存儲(chǔ)過(guò)程) js框架:Jquery/ajax 數(shù)據(jù)庫(kù)名稱:archives2008-03-03ASP 支持中文的len(),left(),right()的函數(shù)代碼
在用ASP處理文字時(shí)。系統(tǒng)自帶的字符串長(zhǎng)度檢測(cè)函數(shù)有時(shí)候也不是很好用。2010-05-05