Strange Things...Advice Please! (form load)

kAnne

Active member
Joined
Jan 17, 2006
Messages
26
Programming Experience
1-3
Okay, Ill have to break this down a little bit, so you know what im on about!

My program is an app 4 kids. Its built in FMX and VB.NET.
When a user clicks on a button in the flash app (embedded into VB.NET form1) it opens a new form (form2) and connects to a database which holds questions for a quiz.

The thing is, I have to open it (form2), then close it, then open it again in order for the data pulled from the DB to be visible.

Why does it do this? Heres my code....

VB.NET:
If e.command = "Saxons" Then
            F2.ShowDialog()
            'set the connection variable
            con = New OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;Data Source= C:\db.mdb;")
            'open the connection
            con.Open()
            tablename = "Saxons"
            subject = e.args
            cmd = New OleDbCommand("SELECT * from " & tablename & " WHERE subject = '" & subject & "'", con)
            reader_saxons = cmd.ExecuteReader
            While reader_saxons.Read()
                F2.question.Text = reader_saxons(2)
                F2.answer1.Text = reader_saxons(3)
                F2.answer2.Text = reader_saxons(4)
                F2.answer3.Text = reader_saxons(5)
                reader_saxons.Close()
                con.Close()
            End While
        End If

Thanks :)
 
F2.ShowDialog()

Code after this line will not be performed until form 2 is closed, that is what .ShowDialog does. Either move that line to the end or just use .Show

Hope that helps,
 
Yep, that worked. Thanks :)

Only now, when I close the form, and click on another subject (which creates a new SQL to pick questions for that subject from DB) the form wont open at all.
 
Never mind, sorted it now. Just move F2.showdialog to the end of the while loop. Had it in the wrond end place!

Thanks :)
 
Back
Top