colonial viper
Member
- Joined
- Apr 6, 2005
- Messages
- 6
- Programming Experience
- Beginner
i have created a database with two tables,(tblQuestions and tblAnswers),the aim is to pull one questions at a time from the tblQuestions and using radion buttons pull 5 answers for each question randomly from the table.I am using textboxes for the questions with five radiobuttons below it with thier texts being the answers.Then a submit button will carry on to the next question but i cant get the question table to read the next row it just reads the first row again.
the problem is the that the following code only takes the first question from the table and not the next row and for the answers goes stright to the last row rather than the correct answer.
Any ideas or advise on how to go about this correctly welcome.
dr(0) etc only takes me to a row how can i get it to go down the list as well.
My apologies if i have asked to much or posted incorrectly but am desperate now.
the problem is the that the following code only takes the first question from the table and not the next row and for the answers goes stright to the last row rather than the correct answer.
Any ideas or advise on how to go about this correctly welcome.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\project.mdb;")
cn.Open()
cmd = New OleDbCommand("select * from tblQuestions", cn)
dr = cmd.ExecuteReader
While dr.Read()
Label3.Text = dr(0)
TextBox2.Text = dr(1)
TextBox3.Text = dr(2)
TextBox7.Text = dr(3)
TextBox8.Text = dr(4)
TextBox9.Text = dr(5)
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub
------------------------ ------------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\project.mdb;")
cn.Open()
cmd = New OleDbCommand("select Answer from tblAnswers", cn)
dr = cmd.ExecuteReader
While dr.Read()
TextBox4.Text = dr(0)
TextBox5.Text = dr(1)
RadioButton1.Text = dr(0)
End While
Catch
End Try
dr.Close()
cn.Close()
End Sub
dr(0) etc only takes me to a row how can i get it to go down the list as well.
My apologies if i have asked to much or posted incorrectly but am desperate now.
Last edited: