470,619 Members | 1,863 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

Array help

Need some help with an array problem.

I am pulling several rows from my database and placing them into an array
successfully but I want to be able to pull them randomly. I can't decide the
best way to proceed, whether to create another array with the DB ID's and
then run a check each time I generate a random number against this array? Or
should I delete the record from the array each time through with the random
number?

Any ideas?

Jul 19 '05 #1
3 1786
You can retrieve the records in random order when you get the recordset.
See here.

http://rtfm.atrax.co.uk/infinitemonk...es/sql/994.asp

Ray at work

"TGP Thought Meister" <tg*@nowhere.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Need some help with an array problem.

I am pulling several rows from my database and placing them into an array
successfully but I want to be able to pull them randomly. I can't decide the best way to proceed, whether to create another array with the DB ID's and
then run a check each time I generate a random number against this array? Or should I delete the record from the array each time through with the random number?

Any ideas?

Jul 19 '05 #2
"TGP Thought Meister" wrote:

I am pulling several rows from my database and placing them into
an array successfully but I want to be able to pull them randomly...


Depending on your database, you could simply return the records in random
order. In SQL Server, for example, you could use the following:

SELECT ... ORDER BY NEWID()
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
Perfect, thanks.
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
You can retrieve the records in random order when you get the recordset.
See here.

http://rtfm.atrax.co.uk/infinitemonk...es/sql/994.asp

Ray at work

"TGP Thought Meister" <tg*@nowhere.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Need some help with an array problem.

I am pulling several rows from my database and placing them into an array successfully but I want to be able to pull them randomly. I can't decide the
best way to proceed, whether to create another array with the DB ID's and then run a check each time I generate a random number against this

array? Or
should I delete the record from the array each time through with the

random
number?

Any ideas?


Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by point | last post: by
2 posts views Thread by Antti Nummiaho | last post: by
8 posts views Thread by Gactimus | last post: by
7 posts views Thread by ritchie | last post: by
5 posts views Thread by ritchie | last post: by
8 posts views Thread by intrepid_dw | last post: by
3 posts views Thread by George | last post: by
3 posts views Thread by inkexit | last post: by
5 posts views Thread by fluk | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.