Click here to Skip to main content
13,052,342 members (53,043 online)
Rate this:
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
Updated 16-Jan-13 4:05am
Zoltán Zörgő 16-Jan-13 7:43am
You are using my answer:, but you have not accepted it :(
rastogi.siddharth 16-Jan-13 7:48am
Take help from this link, which is very nice article:-
Zoltán Zörgő 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2017
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