My code below works fine to execute a SQL script.
However I need to add a progress bar to indicate progress
when the script is long and takes longer to execute.
How do I implement it?

    Public Class Form1  

        Public Sub ShellandWait(ByVal ProcessPath As String)
            Dim objProcess As System.Diagnostics.Process
                objProcess = New System.Diagnostics.Process()
                objProcess.StartInfo.FileName = ProcessPath
                objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal

                'Wait until the process passes back an exit code 

                'Free resources associated with this process
                MessageBox.Show("Could not start process " & ProcessPath, "Error")
            End Try
        End Sub

        Private Sub btnInstall_Click(sender As System.Object, e As System.EventArgs) Handles btnInstall.Click

        End Sub

        Private Sub btnBrowse_Click(sender As System.Object, e As System.EventArgs) Handles btnBrowse.Click
            Dim dlg As OpenFileDialog = New OpenFileDialog()
            dlg.Filter = "SQL files | *.sql"
            If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
                lblPath.Text = dlg.FileName
            End If
        End Sub

        Private Sub btnClose_Click(sender As System.Object, e As System.EventArgs) Handles btnClose.Click
        End Sub
    End Class

Recommended Answers

All 6 Replies

However I need to add a progress bar to indicate progress

I don't think you can. You are starting a new process, which I doubt is returning progress information. You can start by trying to grab any output. Which application are you starting specifically?

I am running a long T-SQL script that creates objects for a database.

Im using vb.net 2010 and scripts were tested in sql server mgt studio(using sql express 2008).Is that what you mean? I mean dont quite get your question.

So most like mgt studio executes the sql file. That means most likely that you can't get feedback on the progress.

I have used SMO before and even those do not provide any feedback other than success or failure.

Oh I get what you meant. I just imported SMO dlls, modified the code but it didnot work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.