private void btnBackup_Click(object sender, EventArgs e) { BackupDatabase("RPSJDB","Sa","manish","VS","c:\\RPSJ.mdf"); // Back(); } public void BackupDatabase(String databaseName, String userName,String password, String serverName, String destinationPath) { Backup sqlBackup = new Backup(); sqlBackup.Action = BackupActionType.Database; sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString(); sqlBackup.BackupSetName = "Archive"; sqlBackup.Database = "RPSJDB"; BackupDeviceItem deviceItem = new BackupDeviceItem("c:\\RPSJDB\\mk.mdf", DeviceType.File); ServerConnection connection = new ServerConnection("VS", "Sa", "manish"); Server sqlServer = new Server(connection); Database db = sqlServer.Databases["RPSJDB"]; sqlBackup.Initialize = true; sqlBackup.Checksum = true; sqlBackup.ContinueAfterError = true; sqlBackup.Devices.Add(deviceItem); sqlBackup.Incremental = false; sqlBackup.ExpirationDate = DateTime.Now.AddDays(3); sqlBackup.LogTruncation = BackupTruncateLogType.Truncate; sqlBackup.FormatMedia = false; sqlBackup.SqlBackup(sqlServer); }
ServerConnection connection = new ServerConnection("VS", "Sa", "manish");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)