473,216 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

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 1821
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: point | last post by:
Hi there.. I have the folowing array => property = hexonet => property = 2003-12-01 18:46:20.0 => property = hexonet => property = 2003-12-02 02:59:15.0 => property = hexonet =>...
2
by: Antti Nummiaho | last post by:
Consider the following javascript: var temp = new Array(new Array(0)) document.writeln(temp) temp = new Array(new Array(0,1)) document.writeln(temp) One would assume that it would print "0...
8
by: Gactimus | last post by:
I made the program below. It outputs the smallest number in the array. What I would like to know is how do I output the array location. I am at a loss. For example, since the smallest number in...
7
by: ritchie | last post by:
Hi all, I am new to this group and I have question that you may be able to help me with. I am trying to learn C but am currently stuck on this. First of all, I have a function for each sort...
5
by: ritchie | last post by:
Hi, I am writing to ask if anyone can see why my array is not being sorted correctly? It's an array of 4 elements(ints 1,2,3,4) but after calling the selection sort it comes back sorted as...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
3
by: inkexit | last post by:
I need help figuring out what is wrong with my code. I posted here a few weeks ago with some code about creating self similar melodies in music. The coding style I'm being taught is apparently a...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
5
by: fluk | last post by:
Hi Guys, I hope someone can help me with this, because i'm getting crazy to find a good way to do that! This is what I got by querying a db. $arr1 = array("site", "description", "area1" ,...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.