error while backup DB from C# "Backup failed for Server" [modified]
C#
2
Posts
2
Posters
1
Views
1
Watching
-
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
-
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
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.”