|
-
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()
Last edited by galgal5814; 03-10-2006 at 03:05 AM.
Similar Threads
-
By Nancy in forum Database
Replies: 2
Last Post: 01-11-2002, 09:38 PM
-
By bigbastard4 in forum Database
Replies: 2
Last Post: 05-16-2001, 06:24 PM
-
By Nirit Touboul in forum Database
Replies: 7
Last Post: 02-25-2001, 11:34 AM
-
By malikmehmood in forum Database
Replies: 0
Last Post: 11-20-2000, 05:12 AM
-
By ranga raghunathan in forum Enterprise
Replies: 0
Last Post: 03-18-2000, 09:59 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks