asp access 随机记录不重复

写这个的东西人多了,小网站偶尔也要用一下

自己也写一个

 

Randomize

dim i:i=0

sql="select id,caption from table"

set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3

lngCount = rs.RecordCount
redim idList(lngCount)
 while i<lngCount

     lngRnd = Int((lngCount * Rnd) + 1)
     rs.AbsolutePosition = lngRnd
     if isEmpty(idList(lngRnd)) then

          response.write rs(0)&"<Br>"

          idList(lngRnd)=1

          i=i+1

     end if

wend

rs.close

set rs=nothing

Erase idList

posted @ 2009-03-30 17:07  alex hu  阅读(362)  评论(0编辑  收藏  举报