randomly select quiz questions


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: randomly select quiz questions

Threaded View

  1. #1
    Join Date
    Dec 2005
    Posts
    51

    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 04:05 AM.

Similar Threads

  1. How do I find duplicate records?
    By Nancy in forum Database
    Replies: 2
    Last Post: 01-11-2002, 10:38 PM
  2. SQL Tutorial (Answer Q's & post your reply)
    By bigbastard4 in forum Database
    Replies: 2
    Last Post: 05-16-2001, 07:24 PM
  3. Get 10 months forward with select statment
    By Nirit Touboul in forum Database
    Replies: 7
    Last Post: 02-25-2001, 12:34 PM
  4. Stored Procedure (Want looping in Cursor)
    By malikmehmood in forum Database
    Replies: 0
    Last Post: 11-20-2000, 06:12 AM
  5. Replies: 0
    Last Post: 03-18-2000, 10: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center