Beispiel #1
0
        private List <DBConnectStatus> GetDBConnectionInfo()
        {
            List <DBConnectStatus> _ret = new List <DBConnectStatus>();

            foreach (ConnectionStringSettings _cstr in ConfigurationManager.ConnectionStrings)
            {
                if (_cstr.ProviderName == "System.Data.OracleClient")
                {
                    DBConnectStatus _st = new DBConnectStatus();
                    _st.ConnectionName = _cstr.Name;
                    CheckConnect(_st, _cstr.ConnectionString);
                    _ret.Add(_st);
                }
            }
            return(_ret);
        }
Beispiel #2
0
        private void CheckConnect(DBConnectStatus _st, string connString)
        {
            int _result = 0;

            using (OracleConnection cn = new OracleConnection(connString))
            {
                try
                {
                    cn.Open();
                    cn.Close();
                    _result           = 1;
                    _st.ResultMessage = "";
                }
                catch (Exception ex)
                {
                    _result           = 3;
                    _st.ResultMessage = ex.Message;
                }
            }
            _st.ConnectResult = _result;
        }