Show progress in progressbar

cacompguy

New member
Joined
Jan 11, 2008
Messages
3
Programming Experience
5-10
Hi,
I am deleteing more than 100,000 records from the table. is there any way to output the progress to progress bar as delete process begins?
I am VS200 vb.net & ADO.Net.

Thank you
 
How are you issuing the "DELETE" command? One command or multiple commands?

If you are sending multiple SQL "DELETE ..." commands, then yes - you can have a progressbar.

If, however, you are only issuing one "DELETE ..." command, then no.
 
If you get no feedback from the methods you call then you can offer the user no feedback. As has been said, if you simply call Update on a DataAdapter or TableAdapter, or else you call ExecuteNonQuery on a Command and it deletes every record then how can you show a progress? The method doesn't tell you anything until it completes so how can you tell the user anything until the method completes?

Only if you're calling ExecuteNonQuery multiple times can you provide feedback to the user in between each call. If you really need progress then you can do this but it will be slower than a batch operation.

The best bet for you is to just use a ProgressBar with its Style set to Marquee. That way the user knows that something is happening, even if they don't know exactly what.
 
How about using System.ComponentModel.Backgroundworker component? Not sure how to use it though..

You'd use a ProgressBarManager if you were having a progress bar reporting progress on a running operation that it was possible to get any indication of progress on, but you arent running an operation that it is possible to get the progress of, so you wont provie a progress bar because you cant. I normally just tell the user how long the operation took last time, and how long it's taken this time. At least the clock ticking up shows them the app hasnt crashed..

The suggestions from the others, of running 100,000 delete queries individually, or in blocks of X records, are good ones though breaking down the atomicity of the database operation will hit performance and may lengthen any transactions or push them over rollback limits, if youre looking to provide rollback.
 
That sux!! Well It takes almost 10 to 15 mins to delete that much records, depending on network traffic. I dont care if progress bar should show very accurate results but the results should be consistent what is being displayed. I have status bar showing "Deleting records from xxx" in one panel and progress bar for that operation in 2nd panel. What is efficient way to do this? Unfortunately I am using only one delete statement.
 
At this point... display a message "Deleting, Please Wait..." or do what Microsoft does randomly spit out a time estimate for completion and as it gets closer to finishing add 10 minutes, subtract 1 or 2 here and there :)


Note: I am joking about the time estimate; but, I think we've all been there waiting M$ 10 minutes when 30 minutes has elapsed.
 
Going on what Pete suggested...

Just create a random number between 1 and 20 (if you're current delete times take 15 mins at most) and have a messagebox to the user with

"Please be patient while records are deleted. This could take {random number here} minutes. It may be less. It may be more. I can't really tell you."
then as JM has suggested, just have the progressbar set to Marquee style...

;)
 
Back
Top