如何随机化数据库属性而不重复

时间:2017-12-16 15:19:31

标签: mysql vb.net xampp

这些问题是随机的,但有时也很可能与下一个问题的选择一起重复或再次出现。我认为Order By Rand()导致它或我缺乏某些东西。

Dim n As Integer = 0
    Dim Qid As String = ""
    Dim numItems As Integer

     Private Sub QuestionNavigation()
            rdbA.Checked = False
            rdbB.Checked = False
            rdbC.Checked = False
            rdbD.Checked = False

            Dim qDT As DataTable = DTTable("SELECT *", "tblQuestions ORDER by Rand()", "")

            numItems = qDT.Rows.Count
            If (numItems > 0) Then
                If (n < numItems) Then
                    lblQuestionNumber.Text = "Question {" & (n + 1) & "} of {" & qDT.Rows.Count & "}"
                    Qid = qDT.Rows(n).Item(0).ToString()
                    txtQuestion.Text = qDT.Rows(n).Item(1).ToString()

                    Dim qcDT As DataTable = DTTable("SELECT *", "tblChoices", " WHERE QuestionID='" & Qid & "'")
                    txtChoiceA.Text = qcDT.Rows(0).Item(2).ToString()
                    txtChoiceB.Text = qcDT.Rows(1).Item(2).ToString()
                    txtChoiceC.Text = qcDT.Rows(2).Item(2).ToString()
                    txtChoiceD.Text = qcDT.Rows(3).Item(2).ToString()
                Else
                    MessageBox.Show("Congratulation! You have completed the exam. Thank you for your cooperation.", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
                    Close()
                    DisplayForm(frmLogin, frmMain.pnlMain)
                End If
            End If
        End Sub

tblQuestions

 QuestionID Question
    Q170001 A _________ is a group of sentence about one topic. 
    Q170002 It is a natural process of recieving aural and visual stimuli.  
    Q170003 A specific place to show where the departure and arrival gates from other country is seen.  
    Q170004 The term communication was derived from the term _________. 
    Q170005 Human behavior states that the lowest IQ level of a person is ________? 
    Q170006 These are the most prominent and cognitive functions distinguishing human being to animals. 
    Q170007 The price of these jeans _____ reasonable.  
    Q170008 What as the most important tool that they used to reach the tiny whaling station of Stromness?  0
    Q170009 The _______, _______, ________, _______ balloons add joy to the family. 0
    Q170010 An electronic device system designed to manipulate data.    
    Q170011 The first commercial version of he internet was launched in year
    Q170012 The _________, the first form of todays Internet, was successfully launched in 1969.
    Q170013 The Internet entered the Philippines in 1994, through he initiative of the
    Q170014 Computer Engineer ________ is the guy to than for the electronic mail that had simplified todays communication. 
    Q170015 Email was message was   
    Q170016 The _____ symbol chose to tell which user was "at" which computer   
    Q170017 A _______________ is a technology that allows one to make telephone call using a high speed internet connection instead of using
    an analog phone line.   
    Q170018 A ___________ is a device that converts analog signal from the public telephone network (PIN) info digital signals inside your computer anf vice-versa.

如果需要,我如何应用数组?我目前在名单上有18个问题

0 个答案:

没有答案