Backup failed for Server
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Backup failed for Server

  1. #1
    Join Date
    Jun 2008
    Posts
    57

    Backup failed for Server

    Hi,
    I'm gonna get a SQL backup with below method :

    PHP Code:
    void BackupDatabase(string sConnectstring dbNamestring backUpPath)
    {
        
    using (SqlConnection cnn = new SqlConnection(sConnect))
        {
            
    cnn.Open();
            
    dbName cnn.Database.ToString();

            
    ServerConnection sc = new ServerConnection(cnn);
            
    Server sv = new Server(sc);

            
    // Create backup device item for the backup
            
    BackupDeviceItem bdi = new BackupDeviceItem(backUpPathDeviceType.File);

            
    // Create the backup informaton
            
    Microsoft.SqlServer.Management.Smo.Backup bk = new Backup();
            
    bk.PercentComplete += new PercentCompleteEventHandler(percentComplete);
            
    bk.Devices.Add(bdi);
            
    bk.Action BackupActionType.Database;
            
    bk.PercentCompleteNotification 1;
            
    bk.BackupSetDescription dbName;
            
    bk.BackupSetName dbName;
            
    bk.Database dbName;
            
    //bk.ExpirationDate = DateTime.Now.AddDays(30);
            
    bk.LogTruncation BackupTruncateLogType.Truncate;
            
    bk.FormatMedia false;
            
    bk.Initialize true;
            
    bk.Checksum true;
            
    bk.ContinueAfterError true;
            
    bk.Incremental false;

            
    // Run the backup
            
    bk.SqlBackup(sv);//Exception
        
    }

    But an exception has occurred :

    Code:
    Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server '\\.\pipe\3F103E6E-3FD4-47\tsql\query'
    additional info about the Exception:

    Code:
    {Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server '\\.\pipe\3F103E6E-3FD4-47\tsql\query'. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
    File name: 'Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
    at Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32& statementsToReverse)
    at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
    at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
    at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
    at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQueryWithMessage(StringCollection queries, ServerMessageEventHandler dbccMessageHandler, Boolean errorsAsMessages)
    at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
    at Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
    
    === Pre-bind state information ===
    LOG: User = MDS-PC\MDS
    LOG: DisplayName = Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
    (Fully-specified)
    LOG: Appbase = file:///D:/My Works/C#/Win Form/Reza Restaurant/RezaRestaurant/bin/Release/
    LOG: Initial PrivatePath = NULL
    Calling assembly : Microsoft.SqlServer.ConnectionInfo, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: D:\My Works\C#\Win Form\Reza Restaurant\RezaRestaurant\bin\Release\RezaRestaurant.vshost.exe.Config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
    LOG: Post-policy reference: Microsoft.SqlServer.BatchParser, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
    LOG: Attempting download of new URL file:///D:/My Works/C#/Win Form/Reza Restaurant/RezaRestaurant/bin/Release/Microsoft.SqlServer.BatchParser.DLL.
    LOG: Attempting download of new URL file:///D:/My Works/C#/Win Form/Reza Restaurant/RezaRestaurant/bin/Release/Microsoft.SqlServer.BatchParser/Microsoft.SqlServer.BatchParser.DLL.
    LOG: Attempting download of new URL file:///D:/My Works/C#/Win Form/Reza Restaurant/RezaRestaurant/bin/Release/Microsoft.SqlServer.BatchParser.EXE.
    LOG: Attempting download of new URL file:///D:/My Works/C#/Win Form/Reza Restaurant/RezaRestaurant/bin/Release/Microsoft.SqlServer.BatchParser/Microsoft.SqlServer.BatchParser.EXE.
    
    --- End of inner exception stack trace ---
    at Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
    at RezaRestaurant.Form_تنظیمات_نرم_افزار.BackupDatabase(String sConnect, String dbName, String backUpPath) in D:\My Works\C#\Win Form\Reza Restaurant\RezaRestaurant\Forms\تنظیمات_نرم_افزار.cs:line 260
    at RezaRestaurant.Form_تنظیمات_نرم_افزار.button_تهیه_نسخه_پشتیبان_Click(Object sender, EventArgs e) in D:\My Works\C#\Win Form\Reza Restaurant\RezaRestaurant\Forms\تنظیمات_نرم_افزار.cs:line 177}
    Would you please guide me ?
    Thanks.

  2. #2
    Join Date
    Jun 2008
    Posts
    57

    Re: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Se


  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,098

    Re: Backup failed for Server

    Edited thread Title, for better forum readability

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center