Hi Cor,
This suggestion worked the same.
I am not having a problem with the OleDbDataAdapte r1.Fill.
The program I am coding is for a Test Generator. The program has various
buttons that select individual test. ( over 100 separate test)
The database has 2400 records
Example (have several button like this)
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Me.OleDbSelectC ommand1.Command Text = "SELECT Table1.* FROM Table1
WHERE (ID Between 1 And 10)"
OleDbDataAdapte r1.Fill(DataSet 1, "Table1")
QuestionCounter ()
End Sub
When I run the program it works fine for the first test. I then run another
test the questions and answers load correctly but the question counter is
stuck on "Question 10 of 10", from the last test taken.
Here is an example of the question counter (This works correct for first
test)
Private Sub QuestionCounter ()
Dim Question, Current As Integer
Question = Me.BindingConte xt(DataSet1, "Table1").C ount
Current = Me.BindingConte xt(DataSet1, "Table1").Posit ion + 1
Label1.Text = "Question " & Current.ToStrin g & " of " &
Question.ToStri ng
End Sub
Here is an example of the question advance. (Also works correctly for first
test)
Private Sub NextQuestion()
Dim Question, Current As Integer
Question = Me.BindingConte xt(DsTest11, "Table1").C ount
Current = Me.BindingConte xt(DsTest11, "Table1").Posit ion + 1
If Current.ToStrin g = Question.ToStri ng Then
CloseTest()
Else
Me.BindingConte xt(DsTest11, "Table1").Posit ion += 1
QuestionCounter ()
End If
End Sub
I not sure if it has something to do with initiating another
"OleDbSelectCom mand" .
I think it selects correctly for the second Test because the first question
is correct but Question Counter is not. Is there a way to reset the Count
and Position of
the records selected?
Thanks Perry Langla
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:AE******** *************** ***********@mic rosoft.com...
Perry,
Can you try it changing your code to this.
OleDbDataAdapte r1.Fill(Dataset 1,"Table1")
I get the idea that it is possible that you are filling three or more
tables at the moment.
(The select name in your select string is not the name in your dataset,
Table1, Table2 etc are default ones)
Cor
"Perry Langla" <pl*****@hotmai l.comschreef in bericht
news:D3******** *************** ***********@mic rosoft.com...
>>I can not seem to figure this out, please help. This program worked
perfectly in Visual Studio 2003. The program gets the information from an
Access Database. I am using OleDbSelectComm and to select certain records.
When I run the program and click Button1 the test works OK. The problem is
when I select another Button the correct records appear but the
QuestionCount er is not correct. It shows " Question 10 of 10 ". I think
it has something to do with the Count not releasing.
Here is a sample.
'This is for counting questions
Private Sub QuestionCounter ()
Dim Question, Current As Integer
Question = Me.BindingConte xt(DataSet1, "Table1").C ount
Current = Me.BindingConte xt(DataSet1, "Table1").Posit ion + 1
Label1.Text = "Question " & Current.ToStrin g & " of " &
Question.ToStr ing
End Sub
'This Button for Test 1
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button1.Click
Me.OleDbSelectC ommand1.Command Text = "SELECT Table1.* FROM Table1
WHERE (ID Between 1 And 10)"
OleDbDataAdapte r1.Fill(DataSet 1)
QuestionCounter ()
End Sub
'This Button for Test 2
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button2.Click
Me.OleDbSelectC ommand1.Command Text = "SELECT Table1.* FROM Table1
WHERE (ID Between 11 And 20)"
OleDbDataAdapte r1.Fill(DataSet 1)
QuestionCounter ()
End Sub
'This Button for Test 2
Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button3.Click
Me.OleDbSelectC ommand1.Command Text = "SELECT Table1.* FROM Table1
WHERE (ID Between 21 And 30)"
OleDbDataAdapte r1.Fill(DataSet 1)
QuestionCounter ()
End Sub
Any help would be appreciated.
Thanks Perry Langla pl*****@hotmail .com