In order to extract randomly your questions you have to provide an ordering criterion to your table of questions, a auto-increment field (say
id
) would fit very well.
Then you could use the random number generator (
Random
class) for extracting a random number and use it in your query:
select question from question_table where id=@random_number
If you don't want question repetitions (that is selecting two or more times the same question in the same test) then have a look at the algorithm shown in my tip:
"Random extraction of 5 cards from a deck"[
^].