Home  >  Article  >  Database  >  Access随机显示记录解决方案

Access随机显示记录解决方案

WBOY
WBOYOriginal
2016-06-07 16:23:21960browse

Access随机显示记录(不重复)解决方案: 看了很多人讨论关于access随机取记录的帖子,不才,写了一个随机显示记录的解决方法,希望大家指正。数据库里有5条记录,随机抽取4条。 code -------------------------------------- % '-------------------------数据

Access随机显示记录(不重复)解决方案:

看了很多人讨论关于access随机取记录的帖子,不才,写了一个随机显示记录的解决方法,希望大家指正。数据库里有5条记录,随机抽取4条。

code
--------------------------------------
 

0 '判断是否记录是否已经在数组中 k=int(rnd*Item+1) loop t(k)=1 '第k条记录被选中 next '-------------------------------------- j=1:i=1'定义下标 '-------------------------------------- ' 循环选取数据集objRS中的部分记录存放到数组中 Do While Not objRS.Eof if t(j)=1 then a(i,1)=objRS("id") '记录id a(i,2)=objRS("DataColumn") '记录内容 i=i+1 end if j=j+1 objRS.MoveNext Loop '-------------------------------------- '------------------------------------------------------------------------------- '----------------------------显示内容-------------------- for i=1 to Item Response.write "序号"&a(i,1)&"
" Response.write "内容"&a(i,2)&"

" next '----------------------------显示内容-------------------- '--------------------------- '释放资源 objRs.Close set objRs=nothing objConn.Close set objConn=nothing '--------------------------- %>



Data
 

id DataColumn -------------------------- 1 a 2 b 3 c 4 d 5 e
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn