473,657 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQLDMO.Backup and ProgressBar

Hi all
My requirement is to "on button_click, backup a SQL
database using SQLDMO.Backup object and update the
progress in a ProgressBar. The problem is the progress
bar does not update at all until the very end of the
backup process, when the backup is almost going to be
over, the progress bar updates itself once on a stretch,
which is no use,it is not showing any progress.

SQLDMO documentation says, the SQLDMO.Backup object fires
PercentComplete event every 10% of the process. I
appreciate all your help in figuring this out. Thanks a
lot.

private void button1_Click(o bject sender,
System.EventArg s e)
{
string DatabaseName = "MySqlServerDB" ;
string BackupFileName = PathFileName.Te xt;
string Prefix = " button1_Click: ";

//check if the text box contains a valid backup
name and path
if(!PathFileNam e.Text.EndsWith (".bak"))
{
MessageBox.Show ("Enter a valid Backup
path and file name. ");
goto ExitClick;
}

string BackupDir = Path.GetDirecto ryName
(BackupFileName );
if(!Directory.E xists(BackupDir ))
{
MessageBox.Show ("Invalid Path
specified. ");
goto ExitClick;
}
if(!JobHelperOb j.CheckDiskSpac e(BackupDir))
{
MessageBox.Show ("Insufficie nt disk space
in the drive. Backup will not continue. ");
goto ExitClick;
}

this.Cursor = Cursors.WaitCur sor;
progressBar1.Vi sible = true;

try
{
//declare an instance of SQLDMO.Backup
SQLDMO.Backup DMOBackup = new
SQLDMO.BackupCl ass();
SQLDMO.SQLServe r SqlServerObj = new
SQLDMO.SQLServe rClass();
SqlServerObj.Na me = ".";
SqlServerObj.Lo ginSecure = true;
SqlServerObj.Co nnect(".",null, null);

DMOBackup.Datab ase = DatabaseName;
DMOBackup.Files = BackupFileName;

// Delete the datafile to allow the
application to create a brand new file.
// This will prevent attaching the new
backup data to the old data if there
// is any.
if(File.Exists( BackupFileName) )
File.Delete(Bac kupFileName);

DMOBackup.Perce ntComplete += new

SQLDMO.BackupSi nk_PercentCompl eteEventHandler
(this.SqlBackup PercentComplete );

DMOBackup.SQLBa ckup(SqlServerO bj);
MessageBox.Show ("Backup complete");

this.Cursor = Cursors.Default ;
progressBar1.Vi sible = false;
progressBar1.Va lue = 0;

DMOBackup = null;
}
catch(Exception excep)
{
TraceMessage = " ERROR: " + Prefix +
excep.Message + ". " + e.GetType().ToS tring() + ". " +
" Exception occurred. ";
ErrorMessage = " ERROR: Unable to get the
BackupPath from DAHS table. ";
Log(TraceMessag e);
Log(ErrorMessag e, true);
MessageBox.Show (excep.Message + " Backup failed.
One of the possible causes could be Insufficient disk
space. ");
}
ExitClick:;
}

private void SqlBackupPercen tComplete(strin g message, int
Percent)
{
progressBar1.Va lue = Percent;
progressBar1.Up date();
}
Nov 16 '05 #1
1 7553
an*******@discu ssions.microsof t.com wrote:
Hi all
My requirement is to "on button_click, backup a SQL
database using SQLDMO.Backup object and update the
progress in a ProgressBar. The problem is the progress
bar does not update at all until the very end of the
backup process, when the backup is almost going to be
over, the progress bar updates itself once on a stretch,
which is no use,it is not showing any progress.


Have you tried debugging it to see how many times the event fires?
Try writing to the debug stream (debug.WriteLin e("Text")) in the
eventhandler and see what happens.

Post back with results if required.

HTH
JB
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6660
by: ewm | last post by:
Using InstallShield Developer 7.04. Does anyone know of a good way to detect if SQLDMO is installed? TIA mcpoo
3
2435
by: Verve | last post by:
Hi, how to create an SQL DMO object in .net and use it to enumerate the properties of Sql server. Can we use this object to list properties without logging in to the server?
0
1484
by: Chandra | last post by:
Hi, I tried the following: >>> from win32com.client import DispatchWithEvents >>> class BackupEvent: .... def OnPercentComplete(self, sMessage, nPercent): .... print sMessage, nPercent
1
6333
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I`ve used SQLDMO to make a backup to my database How can I use it to restore database? thanks Mohammed
3
5304
by: T. | last post by:
I dumped VB and adopted C# for this version of Visual Studio. My problem! I am trying to reference an SQLDMO.Database object in C# like so: private SQLDMO.Database dbcurrent; private string dbname; dbname = "Northwind"; dbcurrent = (SQLDMO.Database)sqlsvr.Databases.Item(dbname); But I get this error : No overload for method 'Item' takes '1' arguments.
1
1738
by: C# beginner | last post by:
Hi all, I am using SQLDMO.Backup for backing up SQL server databases. I need to implement a progress bar to show the progress. I have some sample VB code that is like this: Dim WithEvents oBackupEvent As SQLDMO.Backup Set oBackupEvent = oBackup ' enable events
2
5510
by: | last post by:
Hi all, continued from yesterday's posting... I still haven't found a solution to this issue. I put a breakpoint in private void SqlBackupPercentComplete(string message, int Percent) { progressBar1.Value = Percent; progressBar1.Update(); }
1
2554
by: | last post by:
Hi all I am posting this to check if anyone could help me. The problem still persists. I am beginner in C#. Thanks. Subject: SQLDMO.Backup and ProgressBar - help please From: "anonymous@discussions.microsoft.com" <anonymous@discussions.microsoft.com> Sent: 11/11/2004 5:52:10 AM
1
5760
by: PJHORNSA | last post by:
Hi all, I want to create a backup of a database using SQLDMO in C#. But I keep on getting a exception. If anyone can help me by providing code for this, it would be appreciated. Thanks in advance... Code: +++++++++ try {
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.