Click to See Complete Forum and Search --> : 1 random record among TOP 100


BFprout
05-17-2005, 12:12 PM
I'm using ASP and a CSV file for my database.

It has 4 colums: date, time, name, message

I want to sort the records by date and time (I managed to do that), but then I don't know how I can pick one random record among the TOP 100 most recent.

Does anyone have an idea? Any help would be much appreciated.

wmif
05-17-2005, 01:58 PM
you would need to generate a random number in asp code. then loop through with a for loop until you get that number you generated and display that record.

BFprout
05-18-2005, 05:07 AM
But if I was generating a random number, as I'm using dates, how could I be sure that it will pick one number that exists?

I'm thinking that it might be much easier to use an id column, but I haven't found a way using CSV files

wmif
05-18-2005, 12:58 PM
you arent checking for a number that exists. you are generating a number from 1-100 and then stepping through your recordset for that many records. where it stops is your randomly generated record.