Код для случайных записей в наборе записей
<%
'MovingTordomRecord-StevenJones'Extension
Ifnot (запись набора name.bofand name name.eof)
'ResetTheCursorTotheBeginning
If (name stame.cursortype> 0)
Name stame.movefirst
Еще
Name stame.requery
Эндиф
Name name_totalrn = -1
Nameset name_totalrn = name stogle stogle.recordcount'onyworksonsomerecordsets, butmuchfaster
If (record set name_totalrn = -1), затем «Анджифтиддид, не работа, westillhavetocounttherecords».
'CountTheTotalRecordsByiteratingThereChordSet
Name name_totalrn = 0
В то время как (не записывает набор name.eof)
Nameset name_totalrn = nameset name_totalrn+1
Name stame.movenext
Венд
'ResetTheCursorTotheBeginning
If (name stame.cursortype> 0)
Name stame.movefirst
Еще
Name stame.requery
Эндиф
Эндиф
'nowdofinaladjustments, и MovetotherandamRecord
Nameset name_totalrn = nameset name_totalrn-1
Если записать набор name_totalrn> 0then
Рандомизировать
Name stame.moveint (((name_totalrn+1)*rnd)*
Эндиф
Эндиф
'alldone; youshouldalwayscheckforanemptyrecordsetbeforedisplayingdata
%>