主题:  虚心向大家请教!请务必帮我一下!

yzhongyan

职务:普通成员
等级:1
金币:0.0
发贴:49
#12003/8/23 11:45:44
我现在有这样一个想法请学过asp的高手们帮我?
假如我现在做一个db1.mdb,里面有个数据表字段别是id 自动编号 name,a,b,c,d 共五条内容,如果说我现在在数据库里面收集了50条内容,我想要随机抽取其中10条内容,要如何写呢?
我看了很多随机生成的例子,自己也写了很多个文件都不成功,所以向大家请教了。



yzhongyan

职务:普通成员
等级:1
金币:0.0
发贴:49
#22003/8/23 11:49:58
记录集的名称叫做abc,我这样写出错在什么地方啊!请大家回帖!!

<%
' Moving to random record - Steven Jones' Extension
If Not(abc.bof and abc.eof) Then
' reset the cursor to the beginning
If (abc.CursorType > 0) Then
abc.MoveFirst
Else
abc.Requery
End If

abc_totalrn = -1
abc_totalrn = abc.RecordCount ' ony works on some recordsets, but much faster
If (abc_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
abc_totalrn=0
While (Not abc.EOF)
abc_totalrn = abc_totalrn + 1
abc.MoveNext
Wend

' reset the cursor to the beginning
If (abc.CursorType > 0) Then
abc.MoveFirst
Else
abc.Requery
End If

End If

' now do final adjustments, and move to the random record
abc_totalrn = abc_totalrn - 1
If abc_totalrn > 0 Then
Randomize
abc.Move Int((abc_totalrn + 1) * Rnd)
End If
End If
' all done; you should always check for an empty recordset before displaying data
%>



谁染枫林醉

职务:普通成员
等级:1
金币:1.0
发贴:148
#32003/8/23 15:47:35
偶看不懂哎。
If Not(abc.bof and abc.eof) Then
这句是表达什么意思呀