Link to home
Start Free TrialLog in
Avatar of Tigger996
Tigger996

asked on

Question about using the progress bar

I have a app that displays reports.  However, since there is a large amount of data, it takes a bit of time to run my stored procedure and display the report. (BTW the report uses running totals so this also takes a bit of time to generate.  

What I would like to do is show my user something like a progress bar while the dataset and report are being loaded.  Here is my code where and I've hilighted where there are delays where my program looks like it's not responding.


Private Sub ConnectDatabase()
        cn = cCommon.SQLConnect
        da.SelectCommand = New SqlCommand

        With da.SelectCommand
            .Connection = cnEntries
            .CommandType = CommandType.StoredProcedure
            .CommandText = "[entrysummary]"
        End With

        With da.SelectCommand
            .Parameters.Add("@year", year)
            .Parameters.Add("@machine", machine)

        End With
    End Sub
    Private Sub mnuSander2002_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSander2002.Click
        ds.Clear()
        year = 2002
        machine = 1
        ConnectDatabase()
        Dim rptTitle As String
        rptTitle = ""

        da.Fill(ds, "EntrySummary")                    *** I think there's a delay here

        Dim orpt As New YTDSummary
        orpt.SetDataSource(ds)

        rptTitle = "Sander 2002 YTD Summary"

        orpt.SetParameterValue("reportTitle", rptTitle)
        orpt.SetParameterValue("showproducts", "no")
        Dim previewForm As New frmPreviewReport
        previewForm.MdiParent = Me
        previewForm.crViewer.ReportSource = orpt                  *** And maybe somewhere in here.
        previewForm.Text = "Sander 2002 YTD Report"
        previewForm.Show()

So is there anything I can do while this report is being generated so my user doesn't think the program has locked up?

Tigger
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tigger996

ASKER

mnasman,

How do I do something like that with an animated logo?

Just so you know, I have an MDI form - Main, with a menu, when you select  a menu item, the code that is posted runs.  

Tigger
doing an accurate progress bar will be impossible (you don't know the actual progress since the time is being spent out of process in the SQL server).

you could put up a progress bar that was just controlled off of a timer and looped back to 0 or you could as already suggested use an animation.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see.. can you post code for both solutions?

Tigger
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've tried using the animated image in my app. But what happens when it loads the data ( I believe) the whole program quits responding... so it's like it stalls.  So the animated image quits moving.  Is there a way around that?

Tigger
use multiple threads to avoid that.
I have another post started about threads... so if you can help me out I'd really appreciate it.

https://www.experts-exchange.com/questions/21056447/Multithreading-newbie-question.html

I will split points in this section for all your help.

Tigger