Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Backing up database file using SMO error

Backing up database file using SMO error

Scheduled Pinned Locked Moved C#
helpdatabasesysadmindebuggingtutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gamer1127
    wrote on last edited by
    #1

    Hi. I'm having problem with the way I Backup my database. I'm trying to use the SMO now because the first time I tried to backup my database with File.Copy() is I always have errors with the .dbo file that I'm backing up. I always have the error that the file is currently used by another process even if I already closed the connection. Now I'm still having problem with SMO. I encountered a run-time error saying: "the backup failed for the server ROJAI-PC". I don't know how to resolve the problem since I'm new to SMO. Can anyone help me? Here is the code I used:

    private void createBackupToolStripMenuItem_Click(object sender, EventArgs e)
    {
    Server srver = new Server();
    Backup bckup = new Backup();

            bckup.Devices.AddDevice(@"C:\\Documents and Settings\\Jairo Hibaler\\Desktop\\Backup\\MP\\HotelReservationSystem\\HotelReservationSystem\\bin\\Debug\\hotelReservationBackup.bak", DeviceType.File);
            bckup.Database = "HotelReservationDB";
            bckup.Action = BackupActionType.Database;
            bckup.Initialize = true;
            bckup.PercentCompleteNotification = 10;
            bckup.PercentComplete += new PercentCompleteEventHandler(bckup\_PercentComplete);
            bckup.SqlBackup(srver);
        }
    
        private void bckup\_PercentComplete(object sender, PercentCompleteEventArgs e)
        {
            MessageBox.Show(e.Percent.ToString() + "% backed up");
        }
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups