Thursday, September 16, 2010

A record of random access Recordset


Assuming that this data table has a unique ID field, and at least one record. Random access method in which a record is very simple, can be divided into four steps:
1, to obtain records of the total number of n.
2, all the ID number stored in an array
3, generates a random number less than n, m
4, removed from the array of the first m-ID, query data table, record data obtained.
Here is some code:
<%
set conn = Server.CreateObject ('ADODB.Connection')
conn.open ''

'Backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news : 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar . gz xml2dict-read-only (step 1) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap . html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only

set rs = conn.execute ('Select count (id) from someTable')
rCount = rs (0)

'Backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news : 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar . gz xml2dict-read-only (step 2) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap . html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only

set rs = conn.execute ("select id from someTable")
cnt = 1
dim RRs
redim RRs (rCount)
do while not rs.eof
RRs (cnt) = rs (0)
cnt = cnt + 1
rs.movenext
loop

'Backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news : 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar . gz xml2dict-read-only (step 3) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap . html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only

randomize
currentRR = cLng (rnd * rCount +0.5)
ID = RRs (currentRR)

'Backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news : 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar . gz xml2dict-read-only (step 4) backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap . html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only

sql = "select otherfield from someTable where id =" & ID
set rs = conn.execute (sql)
response.write "ID #" & ID & "=" & rs (0)
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
For SQL Server, there are more efficient ways. Such as the design of two stored procedures. I am here just to clarify some ideas, and hope that this idea can also be used in Access and SQL Server.






Recommended links:



OSPF Posts: Frame Relay OSPF-radio host



Best Astronomy



Gmail frequently dropped a SOLUTION



Recommend Newsgroup Clients



Feature library to create instance of IDS Intrusion Analysis (2)



"Fallout 3" aircraft carrier task of THE city of clues and details of the extension



convert avi to mp4 free



Ipod Avi



VIDEO formats



Ulead SmartSaver Pro 3.0 Cheats bit through (c)



"Staying Princess" Mercenary Information Finished



Guide Launchers And Task Managers



World Cup counterparts: Illustrator drawing three cases of Football



Mr. Chen did not rule out approaching completion of the annexation the board Sina Sina



mpeg4 mp4



Comment Genealogy



Deconstruction Huawei: high investment by foreign forces



No comments:

Post a Comment