public ConnectionTask(SqlConnectionSettings connectionSettings, Microsoft.Matrix.Packages.DBAdmin.UserInterface.Sql.SqlDatabaseLoginForm.ConnectType connectType) { this._connectType = connectType; this._database = new SqlDatabase(connectionSettings); }
protected override void PerformTask() { try { Cursor.Current = Cursors.WaitCursor; this._database.Connect(); } catch (System.Exception exception) { this._database = null; this._exception = exception; } finally { Cursor.Current = Cursors.Default; if ((this._database != null) && base.IsCanceled) { SqlDatabase database = this._database; this._database = null; try { database.Disconnect(); } catch { } } base.PostResults(this._connectType, 100, true); } }
private void OnCreateDbLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { PromptDialog dialog = new PromptDialog(base.ServiceProvider); dialog.EntryText = "Enter a name for the new database:"; Label_0017: if (dialog.ShowDialog() == DialogResult.OK) { string s = dialog.EntryValue.Trim(); string message = string.Empty; if (s.Length == 0) { message = "The name must not be empty."; } else if (s.Length > 0x7c) { message = "The name cannot be longer than 124 characters."; } else if (!SqlHelper.IsValidIdentifier(s)) { message = "The name is not valid. Check that it contains valid characters and is not too long."; } if (message.Length > 0) { this.ReportError(message, "Unable to create a database with that name."); goto Label_0017; } this.CollectConnectionSettings(); SqlDatabase database = new SqlDatabase(this.ConnectionSettings); try { database.Connect(); database.CreateDatabase(SqlHelper.RemoveDelimiters(s)); this._connectionSettings.Database = s; base.DialogResult = DialogResult.OK; base.Close(); } catch (Exception exception) { this.ReportError(exception, "Could not create a new database."); goto Label_0017; } finally { database.Disconnect(); } } }
private void OnAsyncConnectCompleted(object sender, AsyncTaskResultPostedEventArgs e) { this.Connecting = false; ConnectType data = (ConnectType) e.Data; ConnectionTask task = sender as ConnectionTask; this._databaseCombo.Text = this._savedDatabaseText; if (((task != this._connectionTask) || task.IsCanceled) && (task.Database != null)) { try { task.Database.Disconnect(); } catch { } return; } if (task.Database == null) { this.ReportError(task.Exception, "Unable to connect to the database."); return; } this._databaseCombo.Items.Clear(); switch (data) { case ConnectType.DropDown: foreach (string str in task.Database.GetDatabaseNames()) { this._databaseCombo.Items.Add(str); } try { this._skipDropDownEvent = true; this._databaseCombo.DroppedDown = false; Application.DoEvents(); this._databaseCombo.DroppedDown = true; Application.DoEvents(); goto Label_0193; } finally { this._skipDropDownEvent = false; } break; case ConnectType.ConnectButton: break; default: goto Label_0193; } this.ConnectionSettings.Database = this._savedDatabaseText.Trim(); SqlDatabase database = new SqlDatabase(this.ConnectionSettings); try { database.Connect(); if (!database.DatabaseExists(this.ConnectionSettings.Database)) { throw new InvalidOperationException(string.Format("A database named '{0}' could not be found. Please check the connection settings and the spelling of the database name.", this.ConnectionSettings.Database)); } base.DialogResult = DialogResult.OK; base.Close(); return; } catch (Exception exception) { this.ReportError(exception.Message, "Unable to connect to the database."); } finally { database.Disconnect(); } Label_0193: task.Database.Disconnect(); }
public SqlTableCollection(SqlDatabase database) : base(database) { this.PopulateCollection(); }
Project IProjectFactory.CreateProject(object creationArgs) { SqlDatabase database = null; if (creationArgs != null) { SqlConnectionSettings connectionSettings = creationArgs as SqlConnectionSettings; if (connectionSettings == null) { throw new ArgumentException("Invalid creationArgs"); } database = new SqlDatabase(connectionSettings); return this.CreateProject(database); } IUIService service = (IUIService) this._serviceProvider.GetService(typeof(IUIService)); if (service != null) { if (!SqlHelper.IsDmoPresent()) { SqlHelper.PromptInstallDmo(this._serviceProvider); return null; } SqlDatabaseLoginForm form = new SqlDatabaseLoginForm(this._serviceProvider); if (service.ShowDialog(form) == DialogResult.OK) { database = new SqlDatabase(form.ConnectionSettings); return this.CreateProject(database); } } return null; }
public SqlDatabaseProject(IProjectFactory factory, IServiceProvider serviceProvider, SqlDatabase database) : base(factory, serviceProvider, database) { this._sqlDatabase = database; this._rootItem = new SqlDatabaseProjectItem(this); }