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
  1. Home
  2. General Programming
  3. C#
  4. error while backup DB from C# "Backup failed for Server" [modified]

error while backup DB from C# "Backup failed for Server" [modified]

Scheduled Pinned Locked Moved C#
databasecsharpsysadminhelp
2 Posts 2 Posters 1 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.
  • N Offline
    N Offline
    Nabawoka
    wrote on last edited by
    #1

    i call this method by button and this exception appeare exception "Backup failed for Server"

        public void BackupDatabase(String databaseName,  String destinationPath)
        {
            Backup sqlBackup = new Backup();
    
            sqlBackup.Action = BackupActionType.Database;
            sqlBackup.BackupSetDescription = "FollowUPBackUP:" + DateTime.Now.ToShortDateString();
            sqlBackup.BackupSetName = "FollowUP";
    
            sqlBackup.Database = databaseName;
    
            BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
            string instantname = @".\\sqlexpress";
            ServerConnection connection = new ServerConnection(instantname);
            Server sqlServer = new Server(connection);
            
            Database db = sqlServer.Databases\[databaseName\];
           
            sqlBackup.Initialize = true;
            sqlBackup.Checksum = true;
            sqlBackup.ContinueAfterError = true;
    
            sqlBackup.Devices.Add(deviceItem);
            sqlBackup.Incremental = false;
    
            sqlBackup.ExpirationDate = DateTime.Now.AddDays(10);
            sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;
    
            sqlBackup.FormatMedia = false;
            
            sqlBackup.SqlBackup(sqlServer);
        }
    

    modified on Wednesday, December 1, 2010 1:17 AM

    H 1 Reply Last reply
    0
    • N Nabawoka

      i call this method by button and this exception appeare exception "Backup failed for Server"

          public void BackupDatabase(String databaseName,  String destinationPath)
          {
              Backup sqlBackup = new Backup();
      
              sqlBackup.Action = BackupActionType.Database;
              sqlBackup.BackupSetDescription = "FollowUPBackUP:" + DateTime.Now.ToShortDateString();
              sqlBackup.BackupSetName = "FollowUP";
      
              sqlBackup.Database = databaseName;
      
              BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
              string instantname = @".\\sqlexpress";
              ServerConnection connection = new ServerConnection(instantname);
              Server sqlServer = new Server(connection);
              
              Database db = sqlServer.Databases\[databaseName\];
             
              sqlBackup.Initialize = true;
              sqlBackup.Checksum = true;
              sqlBackup.ContinueAfterError = true;
      
              sqlBackup.Devices.Add(deviceItem);
              sqlBackup.Incremental = false;
      
              sqlBackup.ExpirationDate = DateTime.Now.AddDays(10);
              sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;
      
              sqlBackup.FormatMedia = false;
              
              sqlBackup.SqlBackup(sqlServer);
          }
      

      modified on Wednesday, December 1, 2010 1:17 AM

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      I'm pretty sure that the error message was longer than just "Backup failed for Server". If it was then it might help people, to help you, if you edited your question to include the full message.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      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