Hi
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?
thanks
Newbie

    Public Class Form1  

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

                'Wait until the process passes back an exit code 
                objProcess.WaitForExit()

                'Free resources associated with this process
                objProcess.Close()
            Catch
                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
            ShellandWait(lblPath.Text)

        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
            Me.Close()
        End Sub
    End Class

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.
e.g.
ShellandWait(mysqlscript.sql)
newbie

Yes, that was obvious, but which program executes that script?

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.
thanks

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.