Can't Show Form While Reading Data Reader

BobDude

Member
Joined
Jan 26, 2007
Messages
5
Programming Experience
Beginner
Maybe I just missed something.
I'm reading data from a reader.
When I read data into a variable, I check for a value.
If the value is something, I show a form to select another value.
Then a row of data is displayed in a datagridview.

It seems the form flashes by and never allows for user interaction.

------------------------------------------------------------------
-- Form1

If Reader.Hasrows Then
Do While Reader.Hasrows
While Reader.Read
...
x = Reader("Data")
If x = "CheckColor" Then Form2.Show

-- Form2

Here is a simple form that has buttons that set a value on a hidden label on the Form2. The user clicks Button3

Sub Botton_Click3()
Label.Text = "Red"
Me.Hide
End Sub

-- Form1

If Form2.Label.Text = "Red" Then Var1 = "A"
If Form2.Label.Text = "Green" Then Var1 = "B"
If Form2.Label.Text = "Blue" Then Var1 = "C"
...
End While
Reader.NextResult()
Loop
End If

Form2.Close

-----------------------------------------------------------------

The Form2 flashes bye and never allows user interaction.
Does anyone see what I'm missing?

Thanks.
 
Showdialog does nothing.

If I replace the form with a msgbox, the process flow gets interrupted and I can query for a response that changes in-line variables.

But the form will not interrupt synchronously like that.

Do I have to create a worker thread process?
How would I do that so the main flow (getting reader data) can be stopped when a value from the reader is a certain value and displays the dialog form?
 
Form2.Showdialog(me) doesn't work either.

We have a form that cannot display and halt processing it seems.

Any other takers?
 
It sounds like your .net framework is broken. ShowDialog halts execution until the shown form is hidden. A MessageBox is just another modal dialog... I have never seen it behave otherwise


Note this is nearly all moot:

If Reader.Hasrows Then
Do While Reader.Hasrows
While Reader.Read


.Read() returns false if there is nothing to read, so you can dispense with the HasRows checks (think about it)
 

Attachments

  • WhatShowDialogDoes.zip
    16.4 KB · Views: 22
  • 17012007.zip
    35.5 KB · Views: 24
Back
Top