Click here to Skip to main content
11,641,971 members (61,494 online)
Rate this: bad
Please Sign up or sign in to vote.

I am creating windows application for create sql server database backup.
It's have done successfully but i want to show progress bar during create database backup in local drive.

my code is:-
string dbName="abc";
SqlConnection con = new SqlConnection(cnString1);
string DestDir = @"C:\DatabaseBackup";
if (!System.IO.Directory.Exists(DestDir))
   SqlCommand cmd = new SqlCommand("BACKUP DATABASE " + dbName + " TO DISK='" + DestDir + "\\" + dbName + ".bak' WITH FORMAT", con);
   MessageBox.Show("Database Backup Created 'C:\\DatabaseBackup\' drive and folder ");
How could that possible in this code?

Thank You.
Ankit Agarwal
Software Engineer
Posted 16-Jan-13 1:39am
Edited 16-Jan-13 4:05am
Zoltán Zörgő at 16-Jan-13 7:43am
You are using my answer:, but you have not accepted it :(
rastogi.siddharth at 16-Jan-13 7:48am
Take help from this link, which is very nice article:-
Zoltán Zörgő at 17-Jan-13 16:26pm
Any progress?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Ankit,

Good question (5+)
However, the answer is simply - No.
Getting events of the backup process is, currently not possible.
so you can't really get a progress bar for this.

[idea] Perhaps you might go around and (if you can estimate the backedup DB size) perform checks on the file size, and then show the estimation percentage on the GUI.

Using Zoltán's MSDN link is good for getting an event at the end, which is some indication but not of the process itself.

* if you do find a miraculous way to perform such a thing, do let us know, will you?


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 285
1 Sergey Alexandrovich Kryukov 159
2 Afzaal Ahmad Zeeshan 145
3 OriginalGriff 110
4 Mika Wendelius 90
0 Mika Wendelius 460
1 DamithSL 353
2 OriginalGriff 315
3 Sergey Alexandrovich Kryukov 179
4 Afzaal Ahmad Zeeshan 169

Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100