Exemple #1
0
        private bool DropDatabase( )
        {
            if (!MessageService.AskQuestion("Are you sure you want to drop the selected database?\nDatabase name: " + _cp.Database))
            {
                return(false);
            }

            ConnectionParams tmp = _cp.CreateCopy();

            tmp.Database = "master";
            DbCmd.DropDb(tmp, _cp.Database, _dbID);
            return(true);
        }
        public static frmDbObjectSearch CreateDBObjectSearchForm(ConnectionParams connParams, string dbName, string caption, string searchText)
        {
            if (connParams == null)
            {
                throw new NullParameterException("Connection params is null!");
            }

            ConnectionParams cp = connParams.CreateCopy();

            if (!String.IsNullOrEmpty(dbName))
            {
                cp.Database = dbName;
            }

            frmDbObjectSearch result = new frmDbObjectSearch();

            result.InitializeForm(caption, cp);

            if (!String.IsNullOrEmpty(searchText))
            {
                try
                {
                    result.AddSearchTextCriteria(searchText);
                    result.PerformSearch();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can not load data!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result.Close();
                    result.Dispose();
                    result = null;
                }
            }
            return(result);
        }
        public static frmObjectGrouping CreateObjectGroupingForm(string caption, ConnectionParams connParams, string dbName)
        {
#if PERSONAL_EDITION
            throw new PersonalEditionLimitation();
#endif

            if (connParams == null)
            {
                throw new NullParameterException("Connection params is null!");
            }

            frmObjectGrouping frm        = new frmObjectGrouping();
            string            tmpCaption = caption;
            if (String.IsNullOrEmpty(tmpCaption) && connParams != null)
            {
                tmpCaption = "Object Grouping " + connParams.Server + " {" + connParams.Database + "}";
            }

            frm.Text    = tmpCaption;
            frm.TabText = tmpCaption;
            ConnectionParams copyConn = connParams.CreateCopy();
            copyConn.Database = dbName;
            if (!frm.InitializeObjectGrouping(copyConn))
            {
                frm.Dispose();
                frm = null;
            }

            return(frm);
        }
Exemple #4
0
		private void CreateNewDestConn()
		{
			ConnectionParams cp = frmConnectionParams.CreateConnection(true);
			if (cp == null)
				return;

			_cpDest = cp.CreateCopy();
			edtDestConn.Text = _cpDest.InfoDbServer;
		}
Exemple #5
0
		private void SelectDestConnFromRepo()
		{
			ConnectionParams cp = frmConnectionRepository.SelectSingleConnection();
			if (cp == null)
				return;

			_cpDest = cp.CreateCopy();
			edtDestConn.Text = _cpDest.InfoDbServer;
		}
Exemple #6
0
 public void LoadRoles(ConnectionParams cp)
 {
     if (cp == null)
     {
         throw new Exception("Connection parameters must be supplied to load data!");
     }
     _cp = cp.CreateCopy();
     PopulateRoles();
 }
Exemple #7
0
        public void InitializeForm(string caption, string searchText, ConnectionParams connParams)
        {
            if (connParams == null)
            {
                throw new NullParameterException("Connection params object is null!");
            }

            _connParams = connParams.CreateCopy();
            Caption     = caption;
            SearchText  = searchText;
        }
Exemple #8
0
        public void Initialize(string objName, ConnectionParams cp, string dbName, RefDetail refDetail)
        {
            if (cp == null)
            {
                throw new NullParameterException("ConnectionParams is null!");
            }

            _objName    = objName;
            _dbName     = dbName;
            _refDetail  = refDetail;
            _connParams = cp.CreateCopy();
        }
Exemple #9
0
        public void InitializeGenarator(ConnectionParams cp, string tableName, string tableFullName)
        {
            _cp = cp.CreateCopy();
            _initialTableName     = tableName;
            _initialFullTableName = tableFullName;
            _initialDatabaseName  = cp.Database;
            InitializeDataTable();

            txtPrefix.Text    = "sp";
            txtGroup.Text     = cp.Database;
            txtTableName.Text = "_" + tableName;
        }
Exemple #10
0
        public void InitializeDataEditor(string caption, string script, bool isReadonly, ConnectionParams connParams)
        {
            if (connParams == null)
            {
                throw new NullParameterException("Connection params object is null!");
            }

            _connParams = connParams.CreateCopy();
            Caption     = caption;
            Script      = script;
            IsReadOnly  = isReadonly;
        }
Exemple #11
0
        public void InitializeScriptEditor(string script, int objType, ConnectionParams source, string initialCatalog)
        {
            try
            {
                _isInitializing = true;

                if (source == null)
                {
                    throw new NullReferenceException("Connection parameters object can not be null!");
                }

                _script          = script;
                _objectType      = objType;
                _textEditor.Text = _script;

                _connParams = source.CreateCopy();
                if (String.IsNullOrEmpty(initialCatalog))
                {
                    _connParams.InitialCatalog = "master";
                }
                else
                {
                    _connParams.InitialCatalog = initialCatalog;
                }

                _connParams.IsConnected = false;
                try
                {
                    _conn.ConnectionString = _connParams.ConnectionString;
                    _conn.Open();
                    PopulateServers(_connParams.Name);
                    PopulateDatabases(_connParams.InitialCatalog);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can not open connection!\nException:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cmbServers.Items.Clear();
                    cmbServers.Items.Add(_connParams.Name);
                    cmbServers.SelectedIndex = 0;

                    cmbDatabases.Items.Clear();
                    cmbDatabases.Items.Add(_connParams.InitialCatalog);
                    cmbDatabases.SelectedIndex = 0;
                }
            }
            finally
            {
                _isInitializing = false;
            }
        }
        private void AddConnection(ConnectionParams cp)
        {
            string key = ConnectionParams.PrepareConnKeyWithDb(cp);

            if (_selectedConnections.ContainsKey(key))
            {
                return;
            }

            ConnectionParams tmp = cp.CreateCopy();

            _selectedConnections.Add(key, tmp);
            RenderConnectionInList(tmp);
        }
Exemple #13
0
        public void InitializeDataViewer(string windowId, string caption, string script, bool isReadonly, ConnectionParams connParams)
        {
            if (connParams == null)
            {
                throw new NullParameterException("Connection params object is null!");
            }

            _windowId = windowId;
            TableDataEditorManager.Remember(windowId, this);

            _connParams = connParams.CreateCopy();
            Caption     = caption;
            Script      = script;
            IsReadOnly  = isReadonly;
        }
Exemple #14
0
        public static bool DropDatabase(ConnectionParams cp, long dbid)
        {
            if (!MessageService.AskQuestion("Are you sure you want to drop the selected database?\nDatabase name: " + cp.Database))
            {
                return(false);
            }

            ConnectionParams tmp = cp.CreateCopy();

            tmp.Database = "master";
            using (SqlConnection conn = tmp.CreateSqlConnection(true, false))
            {
                DbCmd.DropDb(conn, cp.Database, dbid);
            }
            return(true);
        }
Exemple #15
0
        public static bool TruncateLogs(ConnectionParams cp)
        {
            if (!MessageService.AskQuestion("Are you sure you want to truncate logs for the selected database?\nDatabase name: " + cp.Database))
            {
                return(false);
            }

            ConnectionParams tmp = cp.CreateCopy();

            tmp.Database = "master";
            using (SqlConnection conn = tmp.CreateSqlConnection(true, false))
            {
                DbCmd.TruncLog(conn, cp.Database);
            }
            return(true);
        }
Exemple #16
0
        public static void ShowIndexDBCC(ConnectionParams cp, string owner, int objectId, string objectName, int indexId, string indexName)
        {
            frmIndexDBCC frm = new frmIndexDBCC();

            frm.Caption          = "Index DBCC: " + objectName + "." + indexName + " {" + cp.InfoDbServer + "}";
            frm.ConnectionParams = cp.CreateCopy();

            frm.IndexId     = indexId;
            frm.IndexName   = indexName;
            frm.ObjectOwner = owner;
            frm.ObjectId    = objectId;
            frm.ObjectName  = objectName;

            frm.lblIndexName.Text  = indexName;
            frm.lblObjectName.Text = objectName;

            HostServicesSingleton.HostServices.ShowForm(frm, AddInDockState.Document);
        }
Exemple #17
0
    public void InitializeForm(string caption, ConnectionParams connParams)
    {
      if (connParams == null)
      {
        throw new NullParameterException("Connection params object is null!");
      }


      _isInitializing = true;
      try
      {
        _connParams = connParams.CreateCopy();
        Caption = caption;
        PopulateServerAndDatabaseCombos();
      }
      finally
      {
        _isInitializing = false;
      }
    }
        private void cmbServers_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_initializing)
            {
                return;
            }

            cmbDatabases.Items.Clear();
            ConnectionParams cp = _cpList[cmbServers.SelectedIndex];

            _currentConnPrm = cp.CreateCopy();

            try
            {
                if (_conn != null)
                {
                    if (_conn.State == ConnectionState.Open)
                    {
                        _conn.Close();
                    }
                    _conn.Dispose();
                }

                _conn = cp.CreateSqlConnection(true, false);
                _currentServerIndex = cmbServers.SelectedIndex;
                if (String.IsNullOrEmpty(cp.Database))
                {
                    cp.Database = "master";
                }
                PopulateDatabases(cp.Database);
            }
            catch
            {
                MessageBox.Show("Can not connect to selected server!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _initializing       = true;
                _currentServerIndex = -1;
                _initializing       = false;
            }
        }
Exemple #19
0
        public static frmDataViewer CreateDataViewer(ConnectionParams connParams, string dbName, string tableName, string caption, string script, bool isReadonly, bool autoLoad)
        {
            if (connParams == null)
            {
                throw new NullParameterException("connParams paremeter is null!");
            }

            ConnectionParams cp = connParams.CreateCopy();

            cp.Database = dbName;

            string windowId = TableDataEditorManager.ProduceWindowId(tableName, cp.Server, dbName);

            if (TableDataEditorManager.Contains(windowId))
            {
                return(TableDataEditorManager.Get(windowId));
            }


            frmDataViewer result = new frmDataViewer();

            result.TableName = tableName;
            result.InitializeDataViewer(windowId, caption, script, isReadonly, cp);
            if (autoLoad)
            {
                try
                {
                    result.LoadData(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Can not load data!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result.Close();
                    result.Dispose();
                    result = null;
                }
            }
            return(result);
        }
        internal static frmScriptEditor Create(ObjectInfo objInfo, ConnectionParams cp, string dBName)
        {
            if (objInfo == null)
            {
                throw new InvalidOperationException("ObjectInfo parameter is null!");
            }

            if (cp == null)
            {
                throw new NullParameterException("ConnectionParams paremeter is null!");
            }


            ConnectionParams tmp = cp.CreateCopy();

            if (!String.IsNullOrEmpty(dBName))
            {
                tmp.Database = dBName;
            }

            string script  = ScriptingHelper.GetAlterScript(tmp, objInfo.ObjectID, objInfo.ObjectType);
            string caption = objInfo.ObjectName;

            frmScriptEditor frm      = null;
            string          windowId = ScriptEditorManager.ProduceWindowId(objInfo.ObjectName, objInfo.ObjectID, objInfo.ObjectType, cp.Server, dBName);

            frm = CheckEditorAlreadyExits(windowId, caption, script);
            if (frm != null)
            {
                return(frm);
            }

            frm = new frmScriptEditor();
            frm.InitializeScriptEditor(caption, script, objInfo.ObjectID, objInfo.ObjectType, cp, String.IsNullOrEmpty(dBName) ? cp.Database : dBName);
            return(frm);
        }
Exemple #21
0
 public IndexWrapper(ConnectionParams cp)
     : this()
 {
     _cp = cp.CreateCopy();
 }