Array help

Discussion in 'ASP General' started by TGP Thought Meister, Dec 15, 2003.

  1. 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?
     
    TGP Thought Meister, Dec 15, 2003
    #1
    1. Advertising

  2. TGP Thought Meister

    Ray at Guest

    You can retrieve the records in random order when you get the recordset.
    See here.

    http://rtfm.atrax.co.uk/infinitemonkeys/articles/sql/994.asp

    Ray at work

    "TGP Thought Meister" <> wrote in message
    news:...
    > 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?
    >
    >
    >
     
    Ray at, Dec 15, 2003
    #2
    1. Advertising

  3. "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.
     
    Dave Anderson, Dec 15, 2003
    #3
  4. Perfect, thanks.


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > You can retrieve the records in random order when you get the recordset.
    > See here.
    >
    > http://rtfm.atrax.co.uk/infinitemonkeys/articles/sql/994.asp
    >
    > Ray at work
    >
    > "TGP Thought Meister" <> wrote in message
    > news:...
    > > 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?
    > >
    > >
    > >

    >
    >
     
    TGP Thought Meister, Dec 15, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    13,533
    Old Wolf
    Aug 13, 2004
  2. Eric Boutin
    Replies:
    7
    Views:
    465
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    524
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    236
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    531
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page