Return random cell value of 2 fields
Hi all,
I'm making a generator for Premisses (in film-making this is used to describe the main-characters' development) to generate a random premisse.
A premisse is: "CHARACTERS' MAIN PROPERTY" leads to "SITUATION"
I have a database that has all possible characters' main property in Field1, and the possible situation in field2.
How can I return a random cell value from field1 into label1, and random value from field2 into label2 ?
The connection with the database is set, and the last piece of code is con.open()
Thanks in advance!
Re: Return random cell value of 2 fields
Is this using SQLServer? If so there's a trick you can use with the NEWID function. It generates a random guid so you can use it to randomly order a dataset then pick the first record:-
Select Top 1 * From MyTable Order By NEWID()