public static void BackupDB(string backupDestinationFilePath) { try { // Console.WriteLine("Backup operation started"); Backup backup = new Backup(); //Set type of backup to be performed to database backup.Action = BackupActionType.Database; backup.BackupSetDescription = "BackupDataBase description"; //Set the name used to identify a particular backup set. backup.BackupSetName = "Backup"; //specify the name of the database to back up backup.Database = "DB_Jaggry"; //Set up the backup device to use filesystem. BackupDeviceItem deviceItem = new BackupDeviceItem( backupDestinationFilePath, DeviceType.File); backup.Devices.Add(deviceItem); // Setup a new connection to the data server ServerConnection connection = new ServerConnection(); Server sqlServer = new Server(@"SNEHA-PC\SQLEXPRESS"); //Initialize devices associated with a backup operation. backup.Initialize = true; backup.Checksum = true; backup.ContinueAfterError = true; backup.LogTruncation = BackupTruncateLogType.Truncate; backup.SqlBackup(sqlServer); MessageBox.Show("Backup operation succeeded"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)