vb.net form with a progress bar

using vb.net 2005, I have a form with a progress bar on it, and I want to have the bar update each time it completes a record.

I can have up to 50,000 for this form to process, but I want it to also update a label field on the form, so that I know what record count it is currently on.

Right a few things is not working out for me

1. I can't get the label to update.
2. When I run this app and open another window on top of it, the form does not refresh for me with the current contents of the form.

I am new to doing windows development with .net, so any help on this would be appreciated.

Dim cmdCommand As SqlClient.SqlCommand
        Dim daDataAdapter As SqlClient.SqlDataAdapter
        Dim dsDstData As Data.DataSet
        Dim dtDataTable As Data.DataTable
        Dim strStoredProcName As String = "Proc_Adwords_GetKeywordUrlList"
        Dim strURL As String = ""
        Dim objWebRequest As System.Net.HttpWebRequest
        Dim objWebResponse As System.Net.HttpWebResponse
        Dim streamReader As System.IO.StreamReader
        Dim strHTML As String
        Dim strDbConn As String = "MYFBCONN"


        'Create the sql connection command object
        cmdCommand = New SqlClient.SqlCommand

        Dim objConnection As New SqlConnection(strDbConn)

            With cmdCommand
                daDataAdapter = New SqlClient.SqlDataAdapter
                'Set the command text to the value of the query
                .CommandText = strStoredProcName
                'Set the command type to text for sql query passed into the function
                .CommandType = CommandType.StoredProcedure
                'Set the command object database connection
                .Connection = objConnection
                'Create a new data set
                dsDstData = New DataSet
                'Create a new data set
                dsDstData = New DataSet
                'Set the select statement
                daDataAdapter.SelectCommand = cmdCommand
                'Fill the data adapter with the contents of the query
                daDataAdapter.Fill(dsDstData, "DatabaseData")
                'Set the module level variable for the data table        
                dtDataTable = dsDstData.Tables("DatabaseData")
                'Set the module level variable for the data view
                'dvDataView = New DataView(dsDstData.Tables("DatabaseData"))
                'Clear out the following objects
                daDataAdapter = Nothing
            End With
            If dtDataTable.Rows.Count > 0 Then
                ProgressBar1.Maximum = dtDataTable.Rows.Count
                ProgressBar1.Minimum = 0
                _lngTotalCount = dtDataTable.Rows.Count

            End If
        Catch ex As Exception
        End Try


        'For lngLoop As Integer = 0 To arrList.Count - 1

        Dim strLinkInfo As String
        For Each drRow As Data.DataRow In dtDataTable.Rows

                _lngCount += 1

                ProgressBar1.Step = 25
                ProgressBar1.Value = _lngCount

                strURL = drRow("keyword_url").ToString

                objWebRequest = CType(System.Net.WebRequest.Create(strURL), System.Net.HttpWebRequest)
                objWebRequest.Method = "GET"
                objWebResponse = CType(objWebRequest.GetResponse(), System.Net.HttpWebResponse)

                Dim strHeaders As String = objWebResponse.Headers.ToString
                Dim strMailCode As String = String.Empty
                Dim blnMailCode As Boolean = False

                Dim arr As Array = strURL.ToString.Split(CChar("?"))

                If arr.Length > 0 Then
                    Dim arr2 As Array = arr(1).ToString.Split("&")
                    For lngLo As Long = 0 To arr2.Length - 1
                        If arr2(lngLo).ToString.IndexOf("utm_source") > -1 Then
                            Dim arr3 As Array = arr2(lngLo).ToString.Split("=")

                            If arr3(1).ToString.ToLower.IndexOf("email") > -1 Or arr3(1).ToString.ToLower.IndexOf("socialmedia") > -1 Then
                                blnMailCode = True
                                strMailCode = arr3(1).ToString.ToLower
                                Exit For
                            End If
                        End If

                        If blnMailCode Then
                            If arr2(lngLo).ToString.IndexOf("mailcode") > -1 Then
                                Dim arr3 As Array = arr2(lngLo).ToString.Split("=")
                                strMailCode =  arr3(1).ToString.ToLower
                                Exit For
                            End If
                        End If
                End If
                If strHeaders.ToLower.IndexOf(strMailCode) > -1 Then
                    strLinkInfo &= "1" & Chr(9) & strMailCode & Chr(9)
                    strLinkInfo &= "0" & Chr(9) & "No mailcode present" & Chr(9)
                End If

                strLinkInfo &= strURL & Chr(9)

                Dim strUri As String = objWebResponse.ResponseUri.ToString
                If strUri.ToLower.IndexOf(strURL.ToLower) > -1 Then
                    strLinkInfo &= "1" & Chr(9) & strUri
                    strLinkInfo &= "0" & Chr(9) & "Incorrect url - " & strUri
                End If

                strLinkInfo &= Chr(10) & Chr(13)


            Catch ex As Exception


            End Try


        TextBox1.Text = strLinkInfo

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Try to add an Application.DoEvents() after the ProgressBar1.PerformStep()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jorge PaulinoIT Pro/DeveloperCommented:
The same for the label
JDEE8297Author Commented:
totally forgot about that....:)...I will give it a try tomorrow when I get into work, and see how it goes.
JDEE8297Author Commented:
thanks, that worked like a charm. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.