SMO Backup failed using Sql Server 2008 R2


  • Hello,

    To do database backup with C# I am using the following code:

     Server myServer = new Server(new Microsoft.SqlServer.Management.Common.ServerConnection(lServer, lUserID, lPassword));
                    Microsoft.SqlServer.Management.Smo.Backup oBackup = new Microsoft.SqlServer.Management.Smo.Backup();
                    oBackup.Action = BackupActionType.Database;
                    oBackup.Database = lDatabase;
                    oBackup.Devices.Add(new BackupDeviceItem(mBackupFileName, DeviceType.File));
                    oBackup.Initialize = true;
                    oBackup.Checksum = true;
                    oBackup.ContinueAfterError = true;
                    oBackup.Incremental = false;
                    oBackup.LogTruncation = BackupTruncateLogType.Truncate;
                    oBackup.PercentComplete += new PercentCompleteEventHandler(backup_PercentComplete);
                    oBackup.Complete += new Microsoft.SqlServer.Management.Common.ServerMessageEventHandler(backup_Complete);

    The backup is successfully done with SQL Server 2005, but with SQL Server 2008 R2 the backup is failed and I get this exception: "Backup failed for Server 'localhost\DEV2008'"

    Additional info about the Exception:

     "Failed to conect to server localhost\DEV2008"
    " This SQL Server version(10.50) is not supported"

    Any suggestions would be appreciated.

    Thanks in advance!



    Tuesday, April 19, 2011 10:42 AM


All replies

  • hi,

    Take a look at *Migration SMO Applications*:

    You're using the wrong libraries.

    Microsoft MVP Office Access
    • Marked as answer by fofito11 Tuesday, April 19, 2011 5:04 PM
    Tuesday, April 19, 2011 10:52 AM
  • i am also facing same problem..below is my code. please guide me what is incorrect?
    i have refference to this libraries....
    • Microsoft.SqlServer.ConnectionInfo

    • Microsoft.SqlServer.Smo

    • Microsoft.SqlServer.Management.Sdk.Sfc

                   progressBar1.Maximum = 100;
                   Backup bkup = new Backup();
                    bkup.Action = BackupActionType.Database;
                   bkup.Database = cmbDatabaseName.Text;
                   bkup.Incremental = false;
                   bkup.Devices.Add (new BackupDeviceItem(txtPath.Text, DeviceType.File));
                   bkup.Initialize = true;
                   bkup.PercentCompleteNotification = 10;
                   bkup.PercentComplete += new PercentCompleteEventHandler(backup_PercentComplete);
                         ServerConnection SrvCon = new ServerConnection(cmbServerName.Text);
                         Server srv = new Server(SrvCon);
                    catch (Exception ex)
    Tuesday, November 29, 2011 11:21 AM
  • I don't know. Does it compile? Do you get a run-time error or any kind of other exception?
    Tuesday, November 29, 2011 12:12 PM
  • ya its compiled..
    yes getting run time error....
    Wednesday, November 30, 2011 7:24 AM
  • Please include the necessary facts. What does your run-time error say? The exact message would be helpful.
    Wednesday, November 30, 2011 7:44 AM
  • Run time error saying that  " backup failed for server URVASHI"
    Thursday, December 1, 2011 5:57 AM