/// <summary>The exec load database details.</summary> /// <returns>The exec load database details.</returns> private bool ExecLoadDatabaseDetails() { bool populate = false; string connection = string.Empty; bool success = false; try { _hostWindow.SetPointerState(Cursors.WaitCursor); if (_metaDataService == null) { _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName); } connection = _metaDataService.GetDescription(); populate = true; } catch (Exception exp) { string msg = string.Format( "{0}\r\n\r\nCheck the connection and select 'Reset Database Connection'.", exp.Message); _hostWindow.DisplaySimpleMessageBox(_hostWindow.Instance, msg, "DB Connection Error"); _hostWindow.SetStatus(this, exp.Message); } finally { _hostWindow.SetPointerState(Cursors.Default); } if (populate) { try { _hostWindow.SetPointerState(Cursors.WaitCursor); _model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString); } finally { _hostWindow.SetPointerState(Cursors.Default); } BuildTreeFromDbModel(connection); _hostWindow.SetStatus(this, string.Empty); success = true; } else { _populated = false; DatabaseTreeView.CollapseAll(); } return(success); }
/// <summary>The get tables and views.</summary> private void GetTablesAndViews() { if (_metaDataService == null) { _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName); DbModelInstance model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString); List <string> tableNames = new List <string>(); foreach (DbModelTable table in model.Tables) { tableNames.Add(Utility.MakeSqlFriendly(table.FullName)); } foreach (DbModelView view in model.Views) { tableNames.Add(Utility.MakeSqlFriendly(view.FullName)); } cboTableName.Items.AddRange(tableNames.ToArray()); } }