A simple fix to your existing code would be to just handle the error and get the next random number (repeat). You could do this recursively or in a loop, depending on your current code structure. Another simple option would be to use the random number to look up the index in an array of ID's (for instance produced by GetRows) instead of having the random function produce the ID directly.
And then you have the SQL approach, where you do a select top 1 ... order by Rand. HTH, Tore. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 25, 2002 9:14 AM To: ActiveServerPages Subject: Random picture from a Database I just want to show a random picture form all those in my database. I used to just get the number of pics in my DB, then geta RND # and then call that ID, but, because I Autonumber them, when a pic got deleted, I would sometimes get an error. So, how can I get a rnd Pic ID from a database that has say 20 pics, but 10 are set to NOT be shown....ideas? Tim --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
