Tuesday, July 13, 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.






Recommand Link:



My Favorite Cursors And Fonts



Youtube Backup + Player Now



Youtube to QuickTime Now



Sound WAV Pack



SocuSoft DV To DVD Converter



Ps3 video formats



Hope AVI to DVD Myspace Video



ts file Extension



WorldCup DVD To M4V



SuperBurner YouTube to iPhone



Geography Education Guide



What is a vob file



Youtube Movie to Mobile Phone Utility



Happiness MP3 MPC WMA to VQF Backup



flac to aac



No comments:

Post a Comment