<
%
n = 10 ’’取任意10条记录
set rs = server.CreateObject ( " adodb.recordset " )
sql = " select * from table "
rs.open sql,conn, 1 , 1
count = rs.recordcount ’’记录总数
IF Count <> empty Then
Randomize
for i = 1 to n ’’循环n次
num = Fix ( Rnd * count) ’’num便是随机产生的记录行数,用Fix(),使其不会大于count值。
rs.move num ’’移到改随机行
Response.write rs( 0 ) ’’出该条记录
rs.movefirst ’’别忘了再把指针移到第一条
next
End IF
rs.close
set rs = nothing
% >
n = 10 ’’取任意10条记录
set rs = server.CreateObject ( " adodb.recordset " )
sql = " select * from table "
rs.open sql,conn, 1 , 1
count = rs.recordcount ’’记录总数
IF Count <> empty Then
Randomize
for i = 1 to n ’’循环n次
num = Fix ( Rnd * count) ’’num便是随机产生的记录行数,用Fix(),使其不会大于count值。
rs.move num ’’移到改随机行
Response.write rs( 0 ) ’’出该条记录
rs.movefirst ’’别忘了再把指针移到第一条
next
End IF
rs.close
set rs = nothing
% >