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.StoredProcedur e
.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("re portTitle" , rptTitle)
orpt.SetParameterValue("sh owproducts ", "no")
Dim previewForm As New frmPreviewReport
previewForm.MdiParent = Me
previewForm.crViewer.Repor tSource = 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
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.StoredProcedur
.CommandText = "[entrysummary]"
End With
With da.SelectCommand
.Parameters.Add("@year", year)
.Parameters.Add("@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("re
orpt.SetParameterValue("sh
Dim previewForm As New frmPreviewReport
previewForm.MdiParent = Me
previewForm.crViewer.Repor
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I see.. can you post code for both solutions?
Tigger
Tigger
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Tigger
use multiple threads to avoid that.
ASKER
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
https://www.experts-exchange.com/questions/21056447/Multithreading-newbie-question.html
I will split points in this section for all your help.
Tigger
try these links:
https://www.experts-exchange.com/questions/20763557/vb-NET-Adding-a-progress-bar.html
https://www.experts-exchange.com/questions/20512273/ADO-NET-dataset-to-excel-and-progress-bar-control.html
-Baan