random selection of rows from Access database

Making a Question bank & Want to select rows from a database rando

Page 1 of 1

3 Replies - 6044 Views - Last Post: 01 May 2008 - 07:26 AM Rate Topic: -----

#1 krazzy4  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 01-May 08

random selection of rows from Access database

Post icon  Posted 01 May 2008 - 03:46 AM

Imports System.Data
Imports System.Data.OleDb
Public Class Form4
	 Dim t As Integer = 0
	Dim f2 As New Form2

	Public Function runquiz()
		

		Try
			If t <= nq - 1 Then
				Timer1.Enabled = True
				If con.State = ConnectionState.Open Then con.Close()
				con.Open()
				Dim adp As New OleDbDataAdapter("select * from Tab1", con)
				Dim ds As New DataSet
				adp.Fill(ds)
				Dim dt As DataTable
				dt = ds.Tables(0)
				qbox.Text = dt.Rows(t).Item(1)
				RadioButton1.Text = dt.Rows(t).Item(2)
				RadioButton2.Text = dt.Rows(t).Item(3)
				RadioButton3.Text = dt.Rows(t).Item(4)
				RadioButton4.Text = dt.Rows(t).Item(5)
				t = t + 1
				con.Close()
			Else
				Timer1.Enabled = False
				qbox.Text = "Question"
				RadioButton1.Text = "Option A"
				RadioButton2.Text = "Option B"
				RadioButton3.Text = "Option C"
				RadioButton4.Text = "Option D"
				MsgBox("Thanks for Participation : " & nme & vbCrLf & "Your score is : " & score, MsgBoxStyle.Information, "Completed")

			End If
		Catch ex As Exception
			MsgBox(ex.Message)
		End Try
	End Function
	Public Function validans()
		Dim scr As Integer
		If t = 1 And RadioButton1.Checked Or t = 2 And RadioButton3.Checked Or t = 3 And RadioButton3.Checked Or t = 4 And RadioButton4.Checked Or t = 5 And RadioButton2.Checked Then
			scr = score + 1
			score = scr
			
		End If
	End Function
   
	Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
		MsgBox("Time to complete your test is 30 minutes. Please check the time count.", MsgBoxStyle.Information, "CheckTime")
		On Error Resume Next
		t = 0
		score = 0
		Dim dg1 As New Dialog1
		If dg1.ShowDialog() = Windows.Forms.DialogResult.OK Then
			runquiz()
		End If
	End Sub
	Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Label15.Text = curruser
		RadioButton1.Checked = False
		RadioButton2.Checked = False
		RadioButton3.Checked = False
		RadioButton4.Checked = False
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

		Static i As Integer
		i = i + 1
		If RadioButton1.Checked = True Or RadioButton2.Checked = True Or RadioButton3.Checked = True Or RadioButton4.Checked = True Then
			validans()
			GoTo ter
		End If
		TextBox1.Text = 20 - i

		If i >= 20 Then
ter:		Timer1.Enabled = False
			If t <= nq Then
				qbox.Text = ""
				RadioButton1.Text = ""
				RadioButton2.Text = ""
				RadioButton3.Text = ""
				RadioButton4.Text = ""
				RadioButton1.Checked = False
				RadioButton2.Checked = False
				RadioButton3.Checked = False
				RadioButton4.Checked = False
				i = 0
				runquiz()
			Else
				Exit Sub
			End If
		End If
	End Sub

	Private Sub LinkLabel22_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel22.LinkClicked
		MsgBox("You are logged off successfully")
		Label15.Text = user

	End Sub
End Class

This post has been edited by krazzy4: 01 May 2008 - 04:02 AM


Is This A Good Question/Topic? 0
  • +

Replies To: random selection of rows from Access database

#2 krazzy4  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 01-May 08

Re: random selection of rows from Access database

Posted 01 May 2008 - 04:03 AM

pls help me ...... :)

This post has been edited by krazzy4: 01 May 2008 - 04:07 AM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1634
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: random selection of rows from Access database

Posted 01 May 2008 - 04:40 AM

Can you please post your questions, and not try to put it in the topic description (as that only allows so many characters)
Was This Post Helpful? 0
  • +
  • -

#4 krazzy4  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 01-May 08

Re: random selection of rows from Access database

Posted 01 May 2008 - 07:26 AM

i m making a Vb.net windows application on Online Examination. i have a database/question bank with a answer column in that same database. My problem is that how i connect to the database so that 25 questions are selected randomly from the 100 questions database.And the Score is displayed on the other connected form.Please help me out.Ill be thankful to u.The above code is the coding of that page. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1