/// <summary> /// Display the main window and get the user's server selection when /// the form is loaded. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VerifyBackup_Load(object sender, System.EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh device list GetBackupDevicesList(); } } else { this.Close(); } }
/// <summary> /// Load main form and display the server connect dialog. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ServerInfo_Load(object sender, EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); // Create the server connection ServerConn = new ServerConnection(); // Create the server connect dialog scForm = new ServerConnect(ServerConn); // Display the server connect dialog dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh server information ShowServerInformation(); } } else { this.Close(); } }
private void LoadRegAssembly_Load(object sender, System.EventArgs e) { ServerConnection myServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); myServerConn = new ServerConnection(); scForm = new ServerConnect(myServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (myServerConn.SqlConnectionObject.State == ConnectionState.Open)) { mySqlServer = new Server(myServerConn); if (mySqlServer != null) { this.Text = Properties.Resources.AppTitle + mySqlServer.Name; // Refresh database list ShowDatabases(true); UpdateButtons(); } } else { this.Close(); } }
private void ManageDatabaseUsers_Load(object sender, System.EventArgs e) { ServerConnection myServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); myServerConn = new ServerConnection(); scForm = new ServerConnect(myServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (myServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(myServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh database list ShowDatabases(true); } } else { this.Close(); } }
private void ManageTables_Load(object sender, System.EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh database list ShowDatabases(true); } } else { this.Close(); } }
private void DatabaseDefrag_Load(object sender, EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; Cursor csr = null; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Limit the table properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Schema", "Name", "IsSystemObject" }); ShowDatabases(true); } } else { this.Close(); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { this.Cursor = csr; // Restore the original cursor } }
private void SmoBrowser_Load(object sender, EventArgs e) { ServerConnection ServerConn = new ServerConnection(); ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; } } else { this.Close(); } if (SqlServerSelection != null) { objectTreeView.BeginUpdate(); // By default create Server and Managed Computer nodes objectTreeView.Nodes.Add(CreateNode( String.Format(CultureInfo.CurrentUICulture, Properties.Resources.SQLServerNodeName, SqlServerSelection.Name), SqlServerSelection)); objectTreeView.Nodes.Add(CreateNode( String.Format(CultureInfo.CurrentUICulture, Properties.Resources.ManagedComputerNodeName, SqlServerSelection.Name), new ManagedComputer(SqlServerSelection.Name))); objectTreeView.EndUpdate(); } }
private void BackupRestore_Load(object sender, EventArgs e) { ServerConnection ServerConn = new ServerConnection(); ServerConnect scForm; DialogResult dr; try { // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh database list ShowDatabases(true); } } else { this.Close(); } if (SqlServerSelection != null) { BackupFileTextBox.Text = SqlServerSelection.Settings. BackupDirectory + @"\SmoDemoBackup.bak"; } } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
private void MainForm_Load(object sender, EventArgs e) { ServerConnection ServerConn = new ServerConnection(); ServerConnect scForm; DialogResult dr; try { // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { this.sqlServerSelection = new Server(ServerConn); if (this.sqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + this.sqlServerSelection.Name; // Refresh database list ConnectToServer(ServerConn.ServerInstance); } } else { this.Close(); } } catch (Exception ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } }
private void ConnectToServer() { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); // Load and display the server selection dialog ServerConn = new ServerConnection(); // Set Application name ServerConn.ApplicationName = Application.ProductName; scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if (dr == DialogResult.OK & ServerConn.SqlConnectionObject.State == ConnectionState.Open) { this.SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Refresh database list ShowDatabases(true); // Show server information on StatusBar this.StatusBar.Text = SqlServerSelection.Name + " " + SqlServerSelection.Information.VersionString + " " + SqlServerSelection.Information.ProductLevel; } } scForm = null; }
private void IndexSizes_Load(object sender, EventArgs e) { ServerConnection ServerConn; ServerConnect scForm; DialogResult dr; // Display the main window first this.Show(); Application.DoEvents(); ServerConn = new ServerConnection(); scForm = new ServerConnect(ServerConn); dr = scForm.ShowDialog(this); if ((dr == DialogResult.OK) && (ServerConn.SqlConnectionObject.State == ConnectionState.Open)) { SqlServerSelection = new Server(ServerConn); if (SqlServerSelection != null) { this.Text = Properties.Resources.AppTitle + SqlServerSelection.Name; // Limit the properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Schema", "Name", "IsSystemObject" }); SqlServerSelection.SetDefaultInitFields(typeof(Index), new String[] { "Name", "IndexKeyType", "SpaceUsed" }); ShowDatabases(true); } } else { this.Close(); } }