/// <summary> /// Get information for the selected backup device. /// </summary> /// <param name="BackupDeviceName"></param> private void GetBackupDeviceInfo(string BackupDeviceName) { BackupDevice bkupDevice; // Get the appropriate BackupDevice object from the BackupDevices // collection of a connected SQLServer object. BackupDeviceList = SqlServerSelection.BackupDevices; // Get selected device bkupDevice = BackupDeviceList[BackupDeviceName]; DeviceTypeLabel.Text = bkupDevice.BackupDeviceType.ToString(); StatusLabel.Text = bkupDevice.State.ToString(); LocationLabel.Text = bkupDevice.PhysicalLocation; }
public string[] ListBackupDevices(string ConnectionString) { List <string> backupNames = new List <string>(); Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString))); BackupDeviceCollection backups = server.BackupDevices; for (int i = 0; i < backups.Count; i++) { backupNames.Add(backups[i].Name); } return(backupNames.ToArray()); }
/// <summary> /// Get list of backup devices and add them to the combobox. /// </summary> private void GetBackupDevicesList() { Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear controls BackupDeviceComboBox.Items.Clear(); // Limit the properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(BackupDevice), new String[] { "Name", "BackupDeviceType", "PhysicalLocation" }); // Get the appropriate BackupDevice object from the BackupDevices // collection of a connected SQLServer object. BackupDeviceList = SqlServerSelection.BackupDevices; // Get devices foreach (BackupDevice bkupDevice in BackupDeviceList) { // Add device name to remove combo box BackupDeviceComboBox.Items.Add(bkupDevice.Name); } if (BackupDeviceComboBox.Items.Count > 0) { BackupDeviceComboBox.SelectedIndex = 0; } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
public object GetBackupInformation(string BackupDeviceName, string ConnectionString) { Server server = new Server(new ServerConnection(new SqlConnection(ConnectionString))); BackupDeviceCollection backups = server.BackupDevices; System.Data.DataTable backupHeader = null; for (int i = 0; i < backups.Count; i++) { if (backups[i].Name.ToLower() == BackupDeviceName.ToLower()) { backupHeader = backups[i].ReadBackupHeader(); break; } } return(backupHeader); }