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. SQL SERVER 2008 Express Backup and Restore using SMO does not effect database

SQL SERVER 2008 Express Backup and Restore using SMO does not effect database

Scheduled Pinned Locked Moved C#
databasesql-serversysadminsecurity
12 Posts 2 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.
  • L Lost User

    kutbinayi wrote:

    Please it is a bit urgent, Thanks...

    Not even when the code is on fire. The code looks like it swallows all exceptions. You could try and change the SqlBackupAsync to SqlBackup; might be throwing something async :) --edit; The same question is in the database-forum; choose a forum and stick with it, cross-posting is annoying.

    Bastard Programmer from Hell :suss:

    K Offline
    K Offline
    kutbinayi
    wrote on last edited by
    #3

    Yes but when I use SqlBackup method then it nevers succeed backup operation. and catches an exception on data object System.Collections.ListDictionaryInternals. I think this object is used by SqlBackup method. If I use SqlBackupAsync then no exception is thrown. I catched all exceptions but it is not seen in the above code. I just use it while I was trying. Is it normal that SqlBackupAsync succeeds the backup operation but restoring the database does not affect the database ? What could be other reasons ?

    L 1 Reply Last reply
    0
    • K kutbinayi

      Yes but when I use SqlBackup method then it nevers succeed backup operation. and catches an exception on data object System.Collections.ListDictionaryInternals. I think this object is used by SqlBackup method. If I use SqlBackupAsync then no exception is thrown. I catched all exceptions but it is not seen in the above code. I just use it while I was trying. Is it normal that SqlBackupAsync succeeds the backup operation but restoring the database does not affect the database ? What could be other reasons ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      kutbinayi wrote:

      If I use SqlBackupAsync then no exception is thrown.

      I bet it is, only on another thread. That would mean that there could have been an exception, without it being reported.

      kutbinayi wrote:

      Is it normal that SqlBackupAsync succeeds the backup operation but restoring the database does not affect the database ?

      No, the software usually does as advertised.

      kutbinayi wrote:

      What could be other reasons ?

      Some application open (editing the database) while you're doing a restore? That would lock the database and result in an abort. Can you paste the entire exception that you're getting?

      Bastard Programmer from Hell :suss:

      K 1 Reply Last reply
      0
      • L Lost User

        kutbinayi wrote:

        If I use SqlBackupAsync then no exception is thrown.

        I bet it is, only on another thread. That would mean that there could have been an exception, without it being reported.

        kutbinayi wrote:

        Is it normal that SqlBackupAsync succeeds the backup operation but restoring the database does not affect the database ?

        No, the software usually does as advertised.

        kutbinayi wrote:

        What could be other reasons ?

        Some application open (editing the database) while you're doing a restore? That would lock the database and result in an abort. Can you paste the entire exception that you're getting?

        Bastard Programmer from Hell :suss:

        K Offline
        K Offline
        kutbinayi
        wrote on last edited by
        #5

        The whole exception is this :

        Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server 'EMRE-PC\SQLEXPRESS'. ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: Cannot open backup device 'C:\Users\EMRE\Desktop\YEDEK.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
        BACKUP DATABASE is terminating abnormally.
        konum: Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
        konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
        --- İç özel durum yığını izlemesinin sonu ---
        konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
        konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
        konum: Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
        konum: Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
        konum: Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
        --- İç özel durum yığını izlemesinin sonu ---
        konum: Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
        konum: _15_49KADINIZLEM.DbConnection.BackUpDB(String DBpath) C:\Users\EMRE\documents\visual studio 2010\Projects\15-49KADINIZLEM\15-49KADINIZLEM\DbConnection.cs içinde: satır 107

        Backup failed for Server 'EMRE-PC\SQLEXPRESS'.

        L 1 Reply Last reply
        0
        • K kutbinayi

          The whole exception is this :

          Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server 'EMRE-PC\SQLEXPRESS'. ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: Cannot open backup device 'C:\Users\EMRE\Desktop\YEDEK.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
          BACKUP DATABASE is terminating abnormally.
          konum: Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
          konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
          --- İç özel durum yığını izlemesinin sonu ---
          konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
          konum: Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
          konum: Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
          konum: Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
          konum: Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
          --- İç özel durum yığını izlemesinin sonu ---
          konum: Microsoft.SqlServer.Management.Smo.Backup.SqlBackup(Server srv)
          konum: _15_49KADINIZLEM.DbConnection.BackUpDB(String DBpath) C:\Users\EMRE\documents\visual studio 2010\Projects\15-49KADINIZLEM\15-49KADINIZLEM\DbConnection.cs içinde: satır 107

          Backup failed for Server 'EMRE-PC\SQLEXPRESS'.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          Cannot open backup device 'C:\Users\EMRE\Desktop\YEDEK.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
          BACKUP DATABASE is terminating abnormally.

          There's your answer. Try a different path.

          Bastard Programmer from Hell :suss:

          K 2 Replies Last reply
          0
          • L Lost User

            Cannot open backup device 'C:\Users\EMRE\Desktop\YEDEK.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
            BACKUP DATABASE is terminating abnormally.

            There's your answer. Try a different path.

            Bastard Programmer from Hell :suss:

            K Offline
            K Offline
            kutbinayi
            wrote on last edited by
            #7

            what could be the reason of not accepting this file path ? Because there is no restriction to save file to my Desktop folder.

            L 1 Reply Last reply
            0
            • K kutbinayi

              what could be the reason of not accepting this file path ? Because there is no restriction to save file to my Desktop folder.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #8

              kutbinayi wrote:

              what could be the reason of not accepting this file path ? Because there is no restriction to save file to my Desktop folder.

              This is the place where you post whether a different path actually worked or not. Is there a readonly-file in that location?

              Bastard Programmer from Hell :suss:

              1 Reply Last reply
              0
              • L Lost User

                Cannot open backup device 'C:\Users\EMRE\Desktop\YEDEK.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
                BACKUP DATABASE is terminating abnormally.

                There's your answer. Try a different path.

                Bastard Programmer from Hell :suss:

                K Offline
                K Offline
                kutbinayi
                wrote on last edited by
                #9

                Ok, but why this does not occur when I use SqlBackupAsync method ?

                L 1 Reply Last reply
                0
                • K kutbinayi

                  Ok, but why this does not occur when I use SqlBackupAsync method ?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  kutbinayi wrote:

                  Ok, but why this does not occur when I use SqlBackupAsync method ?

                  It does. It fails, throwing the exact same exception on another thread. Methods that end with "Async" are executed in a different thread, and you don't get the exceptions that they throw.

                  Bastard Programmer from Hell :suss:

                  K 1 Reply Last reply
                  0
                  • L Lost User

                    kutbinayi wrote:

                    Ok, but why this does not occur when I use SqlBackupAsync method ?

                    It does. It fails, throwing the exact same exception on another thread. Methods that end with "Async" are executed in a different thread, and you don't get the exceptions that they throw.

                    Bastard Programmer from Hell :suss:

                    K Offline
                    K Offline
                    kutbinayi
                    wrote on last edited by
                    #11

                    Ok, thank you for all of your replies. As a result using SqlBackup method instead of SqlBackupAsync is better solution for me. And if i solve the file path problem in my code, then everything seems to work great, right.

                    L 1 Reply Last reply
                    0
                    • K kutbinayi

                      Ok, thank you for all of your replies. As a result using SqlBackup method instead of SqlBackupAsync is better solution for me. And if i solve the file path problem in my code, then everything seems to work great, right.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #12

                      kutbinayi wrote:

                      Ok, thank you for all of your replies.

                      You're welcome :)

                      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