Hi all, my skills are novice at best when it comes to VB, so hope someone can lead me in the right direction.
Within a simple app, I have a process which returns results for a few select statements on a SQL DB and then runs a procedure. For each step I am attempting to update a listview control to show the steps to the user. Everything works great except all of the steps only display after the entire routine is completed.
I am thinking that I need to run two processes via the background worker but I am looking for feedback on the best practices to achieve this goal.
Not sure if you need my current code to make a reasonable assessment but here is a tidbit. This example will show how i am updating the listview during a sequence of events.
-----------
Main.lbStatusList.Items.Add("Processing")
Main.lbStatusList.Items(2).SubItems.Add("? Calculating source version transactions")
' SQL check for existing trans
Dim sqltransCount = New SqlCommand("Select ISNULL(count(sotrid),0) as [result] from sotr where trtpId = " & Main.cmbFromTT.SelectedValue("trtpId"), conn)
Dim sqltransDR As SqlDataReader
sqltransDR = sqltransCount.ExecuteReader
While sqltransDR.Read
Main.lbStatusList.Items(2).Text = "Completed"
Main.lbStatusList.Items(2).StateImageIndex = 1
Main.lbStatusList.Items.Add("Completed")
Main.lbStatusList.Items(3).SubItems.Add("? " & sqltransDR("result") & " transactions found in source version")
Main.lbStatusList.Items(3).StateImageIndex = 1
End While
--------------
Do I need a seperate process to run the SQL or is there a method to write to the listview control. I don't quite understand why the current code does not work.
Thanks in advance,
Mike
Within a simple app, I have a process which returns results for a few select statements on a SQL DB and then runs a procedure. For each step I am attempting to update a listview control to show the steps to the user. Everything works great except all of the steps only display after the entire routine is completed.
I am thinking that I need to run two processes via the background worker but I am looking for feedback on the best practices to achieve this goal.
Not sure if you need my current code to make a reasonable assessment but here is a tidbit. This example will show how i am updating the listview during a sequence of events.
-----------
Main.lbStatusList.Items.Add("Processing")
Main.lbStatusList.Items(2).SubItems.Add("? Calculating source version transactions")
' SQL check for existing trans
Dim sqltransCount = New SqlCommand("Select ISNULL(count(sotrid),0) as [result] from sotr where trtpId = " & Main.cmbFromTT.SelectedValue("trtpId"), conn)
Dim sqltransDR As SqlDataReader
sqltransDR = sqltransCount.ExecuteReader
While sqltransDR.Read
Main.lbStatusList.Items(2).Text = "Completed"
Main.lbStatusList.Items(2).StateImageIndex = 1
Main.lbStatusList.Items.Add("Completed")
Main.lbStatusList.Items(3).SubItems.Add("? " & sqltransDR("result") & " transactions found in source version")
Main.lbStatusList.Items(3).StateImageIndex = 1
End While
--------------
Do I need a seperate process to run the SQL or is there a method to write to the listview control. I don't quite understand why the current code does not work.
Thanks in advance,
Mike