SQL SERVER 2008 Express Backup and Restore using SMO does not effect database
-
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
toSqlBackup
; 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:
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 ?
-
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 ?
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:
-
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:
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 107Backup failed for Server 'EMRE-PC\SQLEXPRESS'.
-
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 107Backup failed for Server 'EMRE-PC\SQLEXPRESS'.
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:
-
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:
-
what could be the reason of not accepting this file path ? Because there is no restriction to save file to my Desktop folder.
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:
-
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:
-
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:
-
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:
-
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.