Example #1
0
        /// <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);
        }