randomly select quiz questions
Halor..I am currently doing an online quiz with vb.net and sql server 2000. 10 questions will be randomly selected from 30 questions. I random select the questions using query. Now I would like to store 10 of the questions into an array but do not know how to do so. Please help.
This is the code I had written:
Sub Populate()
Dim cnn As SqlConnection = _
New SqlClient.SqlConnection _
("Data Source=(local);" & _
"Integrated Security=SSPI;" & _
"Initial Catalog=EELANE")
Dim cmd As SqlClient.SqlCommand = _
New SqlClient.SqlCommand("SELECT TOP 5 * FROM QUIZ", cnn)
Dim dap As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter
dap.SelectCommand = cmd
cnn.Open()
'Populate the dataset
dap.Fill(das, "QUIZ")
Dim cmd1 As SqlClient.SqlCommand = _
New SqlClient.SqlCommand _
("SELECT quiz_id, answer_id, answer_choice, answer_remark " & _
"FROM QUIZ,ANSWER_QUIZ WHERE QUIZ.quiz_id = ANSWER_QUIZ.quiz_id", _
cnn)
dap.SelectCommand = cmd1
cnn.Open()
'Populate the dataset
dap.Fill(das, "QUIZ_ANSWER")
'Close the connection because a dataset is a disconnected data source
cnn.Close()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Call routine for creating dataset
Populate()
'Bind quiz questions to each panel
Dim Question(10)
Dim Answer1()
Dim Answer2()
Dim Answer3()
Dim Answer4()