/// <summary>
        /// int AddConnectionObject(string connectionName, string connectionString)
        /// Add a process specific connection to the connection pool.  If it already exists
        /// then replace it
        /// </summary>
        /// <param name="connectionName"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static int AddConnectionObject(string connectionName, string connectionString)
        {
            bool _found = false;
            connectionObjectsType _connection = new connectionObjectsType();

            try
            {
                // find the connection
                for (int n=0;n<connectionObjects.Count;n++)
                {
                    _connection = connectionObjects[n];
                    if (_connection.connectionLevel == "PROCESS")
                    {
                        if (_connection.connectionName.ToUpper() == connectionName.ToUpper())
                        {
                            // replace it
                            _connection.connectionString = connectionString;
                            connectionObjects[n] = _connection;
                            _found = true;
                            break;
                        }
                    }
                }

                if (!_found)
                {
                    // add the connection
                     _connection = new connectionObjectsType();
                    _connection.connectionLevel = "PROCESS";
                    _connection.connectionName = connectionName;
                    _connection.connectionString = connectionString;
                    connectionObjects.Add(_connection);
                }
            }
            catch (Exception ex)
            {
                CommonRoutines.DisplayErrorMessage("$E:" + moduleName + ".AddConnectionObject > " + ex.Message);
            }

            return connectionObjects.Count;
        }
        /// <summary>
        /// connectionObjectsType GetConnectionObject(string connectionObjectName)
        /// Get the connection object for the passed connection object name
        /// </summary>
        /// <param name="connectionObjectName"></param>
        /// <returns></returns>
        public static connectionObjectsType GetConnectionObject(string connectionObjectName)
        {
            connectionObjectsType _connectionObject = new connectionObjectsType();

            try
            {

                for (int n = 0; n < connectionObjects.Count; n++)
                {
                    if (connectionObjectName.ToUpper() == connectionObjects[n].connectionName.ToUpper())
                    {
                        _connectionObject = connectionObjects[n];
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CommonRoutines.DisplayErrorMessage("$E:" + moduleName + ".GetConnectionObject > " + ex.Message);
            }

            return _connectionObject;
        }
        /// <summary>
        /// int GetConnectionObjects()
        /// Get the connection objects defined
        /// </summary>
        /// <returns></returns>
        public static int GetConnectionObjects()
        {
            try
            {
                connectionObjects.Clear();

                // add the main connection defined in the config file (for all users)
                if (MainConnection != "")
                {
                    connectionObjectsType _mainConnection = new connectionObjectsType();
                    _mainConnection.connectionLevel = "SYSTEM";
                    _mainConnection.connectionName = "Main Connection";
                    _mainConnection.connectionDBMS = MainDBMS;
                    _mainConnection.connectionString = MainConnection;
                    connectionObjects.Add(_mainConnection);
                }

                if (CSA.loggedOnAsAdmin)
                {
                    // add the base connection defined in the config file (if user is Admin)
                    if (BaseConnection != "")
                    {
                        connectionObjectsType _baseConnection = new connectionObjectsType();
                        _baseConnection.connectionLevel = "SYSTEM";
                        _baseConnection.connectionName = "Base Connection";
                        _baseConnection.connectionDBMS = BaseDBMS;
                        _baseConnection.connectionString = BaseConnection;
                        connectionObjects.Add(_baseConnection);
                    }
                }

                // get the connection objects
                string _fields = "Process_Id, Widget_Name, Widget_Id, Properties, Last_Values";
                string _criteria = "Process_Level='SYSTEM' " +
                                   "    and Name='DBCONNECTIONS' ";

                List<string[]> _rows = GetProcessWidgets(_fields,_criteria);

                if (_rows.Count > 0)
                {
                    string _fieldList = CommonRoutines.GetFieldString(_rows[0]);

                    for (int n = 1; n < _rows.Count; n++)
                    {
                        string _fieldValues = CommonRoutines.GetFieldString(_rows[n]);

                        string _connectionName = CommonRoutines.GetRowValue(_fieldList, _fieldValues, "Widget_Name");

                        string[] _properties = CommonRoutines.GetRowValue(_fieldList, _fieldValues, "Properties").Split('^');

                        string _dbms = "";
                        string _connectionString = "";

                        for (int m = 0; m < _properties.Length; m++)
                        {
                            if (_properties[m].ToUpper().IndexOf("DBMS=") == 0)
                            {
                                _dbms = _properties[m].Substring(5);
                            }

                            if (_properties[m].ToUpper().IndexOf("CONNECTION=") == 0)
                            {
                                _connectionString = _properties[m].Substring(11);
                            }

                        }

                        if (_dbms != "" && _connectionString != "")
                        {
                            // add the connection
                            connectionObjectsType _connection = new connectionObjectsType();
                            _connection.connectionLevel = "SYSTEM";
                            _connection.connectionName = _connectionName;
                            _connection.connectionDBMS = _dbms;
                            _connection.connectionString = _connectionString;
                            connectionObjects.Add(_connection);
                        }

                    }
                }

                // if the current pallet is set, see if there are any connection objects there
                if (CSA.currentPallet != null)
                {
                    // now add any connection objects on this pallet to the list
                    for (int m = 0; m < CSA.currentPallet.Controls.Count; m++)
                    {
                        Control _control = CSA.currentPallet.Controls[m];
                        if (_control.Tag != null && _control.Tag.GetType().Name.ToUpper() == "IGENFIELD")
                        {
                            IGenField _igenFieldObjectTemp = (IGenField)_control.Tag;
                            if (_igenFieldObjectTemp.type == "CONNECTION")
                            {
                                connectionObjectsType _connection = new connectionObjectsType();
                                _connection.connectionLevel = "IGEN";
                                _connection.connectionName = _igenFieldObjectTemp.name;
                                _connection.connectionString = _igenFieldObjectTemp.GetProperty("Connection");
                                _connection.connectionDBMS = _igenFieldObjectTemp.GetProperty("DBMS");
                                connectionObjects.Add(_connection);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonRoutines.DisplayErrorMessage("$E:" + moduleName + ".GetConnectionObjects > " + ex.Message);
            }

            return connectionObjects.Count;
        }
        /// <summary>
        /// int RenameConnectionObject(string connectionName, string newConnectionName)
        /// Rename the connection to the new name
        /// </summary>
        /// <param name="connectionName"></param>
        /// <param name="newConnectionName"></param>
        /// <returns></returns>
        public static int RenameConnectionObject(string connectionName, string newConnectionName)
        {
            connectionObjectsType _connection = new connectionObjectsType();

            try
            {
                // find the connection
                // find the connection
                for (int n = 0; n < connectionObjects.Count; n++)
                {
                    _connection = connectionObjects[n];
                    if (_connection.connectionLevel == "PROCESS")
                    {
                        if (_connection.connectionName.ToUpper() == connectionName.ToUpper())
                        {
                            // rename it
                            _connection.connectionName = newConnectionName;
                            connectionObjects[n] = _connection;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonRoutines.DisplayErrorMessage("$E:" + moduleName + ".RenameConnectionObject > " + ex.Message);
            }

            return connectionObjects.Count;
        }