Stephen Forte's Blog

 RSS/Feedburner
      Home     Steve & The Tank       

  Tuesday, May 31, 2005

     SDC Day 2-The Damn Progress Meter

 

So last night during the geek night session at the SDC, the Dutch, inspired by Richard Campbell called me on my SMO Backup and Restore GUI that had a progress meter. They thought I was hacking it, not that I was actually providing a true representation of the progress made by the status of the backup. Here is the progress meter in action, as the database backup makes progress we update the progress meter:

 

 

 

To do a backup programmatically you can to use SMO (see yesterday). Begin by setting the variables to get started.

 

Server svr = new Server();//assuming local server

Backup bkp = new Backup();

 

Cursor = Cursors.WaitCursor;

 

Then you have to set the device to backup to and what database to backup. Notice in the comments the code to the progress meter

 

try

{

      string strFileName = txtFileName.Text.ToString();

      string strDatabaseName = txtDatabase.Text.ToString();

                       

      bkp.Action = BackupActionType.Database;

      bkp.Database = strDatabaseName;

 

      //set the device: File, Tape, etc

      bkp.Devices.AddDevice(strFileName, DeviceType.File);

      //set this when you want to do Incremental

      bkp.Incremental = chkIncremental.Checked;

 

      //progress meter stuff

      progressBar1.Value = 0;

      progressBar1.Maximum = 100;

progressBar1.Value = 10;

 

      //this gives us the % complete by handling the event

      //provided by SMO on the percent complete, we will

      //update the progress meter in the event handler

                       

      //set the progress meter to 10% by default

bkp.PercentCompleteNotification = 10;

//call to the event handler to incriment the progress meter

bkp.PercentComplete += new PercentCompleteEventHandler(ProgressEventHandler);

     

//this does the backup

      bkp.SqlBackup(svr);

      //alert the user when it is all done

      MessageBox.Show("Database Backed Up To: " + strFileName, "SMO Demos");

 

                       

                       

      }

catch (SmoException exSMO)

      {

      MessageBox.Show(exSMO.ToString());

 

      }

catch (Exception ex)

      {

      MessageBox.Show(ex.ToString());

      }

 

finally

      {

      Cursor = Cursors.Default;

      progressBar1.Value = 0;

      }

 

 

Here is the ProgressEventHandler, notice that I made it generic enough that I can call it from both the backup and restore methods!

 

public void ProgressEventHandler(object sender, PercentCompleteEventArgs e)

      {

            //increase the progress bar up by the percent

            progressBar1.Value = e.Percent;

      }

 



Speaking | SQL Server | Travel

Tuesday, May 31, 2005 5:28:53 AM (Eastern Standard Time, UTC-05:00)
Comments [1]  |  Trackback Related posts:
SQL Server 2008 RC0-Lost a Few Hours
Impedance Mismatch
See me on Channel 9
WideOpen Web-Bringing People Together
Techdays 2008
SQL Server 2008 XML: XML DML Enhancements
Tracked by:
"http://blastpr.com/wiki/js/pages/cymbalta/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/accutane/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/wellbutrin/index.html" (http://blastpr.com/wik... [Pingback]
"http://morningside.edu/mics/_notes/pages/effexor/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/viagra/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/rainbow-brite/index.html" (http://blastpr.com/... [Pingback]
"http://morningside.edu/mics/_notes/pages/tramadol/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/prilosec/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://morningside.edu/mics/_notes/pages/nexium/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/viagra/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/lipitor/index.html" (http://morningsid... [Pingback]
"http://morningside.edu/mics/_notes/pages/prozac/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://morningside.edu/mics/_notes/pages/claritin/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/celexa/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/cialis/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/synthroid/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://morningside.edu/mics/_notes/pages/paxil/index.html" (http://morningside.... [Pingback]
"http://blastpr.com/wiki/js/pages/celebrex/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/effexor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/hoodia/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/clomid/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/cymbalta/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/paxil/index.html" (http://blastpr.com/wiki/js/... [Pingback]
"http://blastpr.com/wiki/js/pages/soma/index.html" (http://blastpr.com/wiki/js/p... [Pingback]
"http://blastpr.com/wiki/js/pages/nexium/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/lexapro/index.html" (http://morningsid... [Pingback]
"http://blastpr.com/wiki/js/pages/synthroid/index.html" (http://blastpr.com/wiki... [Pingback]
"http://blastpr.com/wiki/js/pages/lipitor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/hoodia/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/tramadol/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://thejohnslater.com/pix/img/docs/42082955/index.html" (http://thejohnslate... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/48335156/index.html" ... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/37348396/index.html" ... [Pingback]
"http://martinrozon.com/images/photos/docs/43274485/index.html" (http://martinro... [Pingback]
"http://lecouac.org/ecrire/lang/docs/77066936/index.html" (http://lecouac.org/ec... [Pingback]
"http://slaterjohn.com/downloads/2col/66689432/index.html" (http://slaterjohn.co... [Pingback]
"http://legambitdufou.org/Library/docs/64933533/index.html" (http://legambitdufo... [Pingback]
"http://lecouac.org/ecrire/lang/docs/30125734/index.html" (http://lecouac.org/ec... [Pingback]
"http://lecouac.org/ecrire/lang/docs/20007231/index.html" (http://lecouac.org/ec... [Pingback]
"http://realestate.hr/templates/css/docs/71546796/index.html" (http://realestate... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/36483653/index.html" ... [Pingback]
"http://coolioness.com/attachments/docs/76375390/index.html" (http://coolioness.... [Pingback]
"http://blog.netmedia.hr/wp-includes/js/docs/91708760/index.html" (http://blog.n... [Pingback]
"http://hrvatska.biz/wp-includes/js/docs/80692203/index.html" (http://hrvatska.b... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/24066563/index.html" (http://ipsilo... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/84431573/index.html" (... [Pingback]
"http://swellhead.netswellhead.net/docs/05235252/index.html" (http://swellhead.n... [Pingback]
"http://thejohnslater.com/pix/img/docs/41914710/index.html" (http://thejohnslate... [Pingback]
"http://thejohnslater.com/pix/img/docs/86193101/index.html" (http://thejohnslate... [Pingback]
"http://realestate.hr/templates/css/docs/28593877/index.html" (http://realestate... [Pingback]
"http://thejohnslater.com/pix/img/docs/73486930/index.html" (http://thejohnslate... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/52060005/index.html" ... [Pingback]
"http://swellhead.netswellhead.net/docs/84545083/index.html" (http://swellhead.n... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/04726190/index.html" (http://vlada... [Pingback]
"http://allfreefilms.com/wp-includes/js/25891222/index.html" (http://allfreefilm... [Pingback]
"http://realestate.hr/templates/css/docs/36157459/index.html" (http://realestate... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/54089144/index.h... [Pingback]
"http://lecouac.org/ecrire/lang/docs/25282359/index.html" (http://lecouac.org/ec... [Pingback]
"http://pddownloads.com/docs/66275653/index.html" (http://pddownloads.com/docs/6... [Pingback]
"http://thebix.com/includes/compat/docs/10152421/index.html" (http://thebix.com/... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/16705258/index.html" (... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/68291686/index.h... [Pingback]
"http://jivest2006.com/docs/40579018/index.html" (http://jivest2006.com/docs/405... [Pingback]
"http://plantmol.com/docs/80639343/index.html" (http://plantmol.com/docs/8063934... [Pingback]
"http://thebix.com/includes/compat/docs/51589391/index.html" (http://thebix.com/... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/60974094/index.h... [Pingback]
"http://entartistes.ca/images/images/docs/28212733/index.html" (http://entartist... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/55227677/index.html" (http://ipsilo... [Pingback]
"http://coolioness.com/attachments/docs/75395149/index.html" (http://coolioness.... [Pingback]
"http://jivest2006.com/docs/42940613/index.html" (http://jivest2006.com/docs/429... [Pingback]
"http://pddownloads.com/docs/21991908/index.html" (http://pddownloads.com/docs/2... [Pingback]
"http://temerav.com/images/menu/91084644/index.html" (http://temerav.com/images/... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/25746442/index.html" (http://vlada... [Pingback]
"http://pspdesktops.com/fileupload/store/docs/18769945/index.html" (http://pspde... [Pingback]
"http://witze-humor.de/templates/images/docs/69259068/index.html" (http://witze-... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/09763218/index.html" (http://vlada... [Pingback]
"http://ncdtnanotechportal.info/generator/docs/87198700/index.html" (http://ncdt... [Pingback]
"abaffy.org/la/img/cialis/" (abaffy.org/la/img/cialis/) [Pingback]
"http://easytravelcanada.info/js/pages/7/nexium/" (http://easytravelcanada.info/... [Pingback]
"http://easytravelcanada.info/js/pages/2/celexa/" (http://easytravelcanada.info/... [Pingback]
"http://easytravelcanada.info/js/pages/12/zoloft/" (http://easytravelcanada.info... [Pingback]
"http://abaffydesign.com/la/img/viagra/" (http://abaffydesign.com/la/img/viagra/... [Pingback]
"http://easytravelcanada.info/js/pages/1/celebrex/" (http://easytravelcanada.inf... [Pingback]
"http://sevainc.com/bad_denise/img/10/synthroid/" (http://sevainc.com/bad_denise... [Pingback]
"http://easytravelcanada.info/js/pages/6/lexapro/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/4/coumadin/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/12/viagra/" (http://easytravelcanada.info... [Pingback]
"http://easytravelcanada.info/js/pages/10/synthroid/" (http://easytravelcanada.i... [Pingback]
"http://ina-tv.sk/img/cialis/" (http://ina-tv.sk/img/cialis/) [Pingback]
"http://jemnemelodierecords.sk/img/viagra/" (http://jemnemelodierecords.sk/img/v... [Pingback]
"http://adventure-traveling.com/images/img/cialis/" (http://adventure-traveling.... [Pingback]
"http://sevainc.com/bad_denise/img/8/paxil/" (http://sevainc.com/bad_denise/img/... [Pingback]
"http://sevainc.com/bad_denise/img/12/viagra/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/11/ultram/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://abaffydesign.com/la/img/cialis/" (http://abaffydesign.com/la/img/cialis/... [Pingback]
"http://sevainc.com/bad_denise/img/4/cymbalta/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/3/clomid/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/1/celebrex/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/6/lipitor/" (http://easytravelcanada.info... [Pingback]
"http://easytravelcanada.info/js/pages/9/prozac/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/11/tramadol/" (http://sevainc.com/bad_denise/... [Pingback]
"http://sevainc.com/bad_denise/img/7/nexium/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://sevainc.com/bad_denise/img/3/claritin/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/8/paxil/" (http://easytravelcanada.info/j... [Pingback]
"http://sevainc.com/bad_denise/img/12/wellbutrin/" (http://sevainc.com/bad_denis... [Pingback]
"http://sevainc.com/bad_denise/img/3/clomid/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://simplecanada.info/js/pages/13912893/" (http://simplecanada.info/js/pages... [Pingback]
"http://sevainc.com/bad_denise/img/5/effexor/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/6/lexapro/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/3/claritin/" (http://easytravelcanada.inf... [Pingback]
"http://odin.net/images/pages/35694472/downloadable-porn-videos.html" (http://od... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/virgin-vagina-pic.html" (... [Pingback]
"http://odin.net/images/pages/35694472/council-of-adult-education-australia.html... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/lisa-rowe-girl-interrupted... [Pingback]
"http://odin.net/images/pages/52807681/britney-sex-tape-just-a-rumor.html" (http... [Pingback]
"http://odin.net/images/pages/52807681/diaper-scat.html" (http://odin.net/images... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/nude-cassie.html" (http:/... [Pingback]
"http://odin.net/images/pages/35694472/pics-of-marilyn-manson.html" (http://odin... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/ravon-nude.html" (http://... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/free-sexualy-graphic-love-... [Pingback]
"http://odin.net/images/pages/35694472/pussy-movie-tralers.html" (http://odin.ne... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/granny-movie-thumbs.html"... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/asian-woman-for-anal-sex.h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/college-girls-escorts.html... [Pingback]
"http://odin.net/images/pages/52807681/marathon-florida-webcam.html" (http://odi... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/cheeta-girls.html" (http:/... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/xxx-asian-anal-milf-free.... [Pingback]
"http://odin.net/images/pages/35694472/study-on-penis-size.html" (http://odin.ne... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/adult-lactation.html" (ht... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/erotic-pictures-of-oral-s... [Pingback]
"http://odin.net/images/pages/35694472/baby-bop-photos.html" (http://odin.net/im... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/andy-kim-baby-i-love-you.... [Pingback]
"http://odin.net/images/pages/35694472/xxx-schoolgirls-hardcore-pictures.html" (... [Pingback]
"http://odin.net/images/pages/52807681/men-women-having-sex-together.html" (http... [Pingback]
"http://odin.net/images/pages/35694472/babe-tv.html" (http://odin.net/images/pag... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/teen-trends-courtney-doll.... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/taylor-hayes-free-pics.ht... [Pingback]
"http://odin.net/images/pages/35694472/time-square-webcam.html" (http://odin.net... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/free-xxx-video-pics.html"... [Pingback]
"http://odin.net/images/pages/35694472/baby-boy-s-name.html" (http://odin.net/im... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/porn-vagina-sex.html" (ht... [Pingback]
"http://odin.net/images/pages/35694472/anglina-jolie-nude.html" (http://odin.net... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/fuck-bitches-get-money-lyr... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/marriage-sex-life.html" (h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/free-xxx-3some-pictures-te... [Pingback]
"http://odin.net/images/pages/35694472/stories-housewives-seducing-husbands-frie... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/statistics-on-teens-allowa... [Pingback]
"http://odin.net/images/pages/52807681/teen-fashion.html" (http://odin.net/image... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/teen-doggystyle-fucking-f... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/blonde-sluts-cocksucking.... [Pingback]
"http://odin.net/images/pages/52807681/boys-and-girls-grinding.html" (http://odi... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/adult-free-gay-porn.html" ... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/caught-masturbating.html" ... [Pingback]
"http://odin.net/images/pages/35694472/index.html" (http://odin.net/images/pages... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/adult-film-star-listings.... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/underwater-girl-nude.html... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/fucking-stories-for-women... [Pingback]
"http://odin.net/images/pages/52807681/erotic-slavery-stories.html" (http://odin... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/i-need-free-party-ideas-fo... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/young-girls-sex-video.html... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/little-match-girl-story.h... [Pingback]
"http://odin.net/images/pages/52807681/index.html" (http://odin.net/images/pages... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/sex-gadis-melayu.html" (ht... [Pingback]



Thursday, February 16, 2006 4:15:05 PM (Eastern Standard Time, UTC-05:00)
This is not really a comment but more of a plea for help...

I'm interested in this progress meter for SMO backups. Im self studying in using C# and SMO. So far I have been able to do back ups but not much error handling yet. I was wondering how I could implement this sample of yours when the progress bar is in a windows form and the back up code is in a class?

I am terribly new at this and I hope that you could help me on this matter.

Thanks in advance for any help or advice.
Comments are closed.









newtelligence dasBlog 2.0.7226.0

Copyright © 2008 Stephen Forte. Available under the Creative Commons Attribution 3.0 License.

 The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way