Example #1
0
        private bool TestOracleConnection(out string errMsg)
        {
            errMsg = string.Empty;
            OracleConnectionStringBuilder oraConnBuilder = new OracleConnectionStringBuilder();

            oraConnBuilder.DataSource = this.Server;
            oraConnBuilder.UserID     = this.UserName;
            oraConnBuilder.Password   = this.Password;
            OPCOracleSQLHelper oraHelper = new OPCOracleSQLHelper(oraConnBuilder.ConnectionString, out errMsg);

            try
            {
                oraHelper.Connected = true;
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }

            string    querClause = string.Format("SELECT * FROM {0} WHERE ROWNUM <= 1", TableName);
            DataTable dt         = oraHelper.QueryRecords(querClause, out errMsg);

            if (dt == null)
            {
                return(false);
            }

            querClause = string.Format("SELECT * FROM {0} WHERE ROWNUM <= 1", HistoryTableName);
            dt         = oraHelper.QueryRecords(querClause, out errMsg);
            return(dt != null);
        }
Example #2
0
        public override bool CreateConnection(out string errMsg)
        {
            OracleConnectionStringBuilder oraConnBuilder = new OracleConnectionStringBuilder();

            oraConnBuilder.DataSource = this.m_oraSvrName;
            oraConnBuilder.UserID     = this.m_userName;
            oraConnBuilder.Password   = this.m_password;
            this.m_oraHelper          = new OPCOracleSQLHelper(oraConnBuilder.ConnectionString, out errMsg);
            try
            {
                this.m_oraHelper.Connected = true;
                this.m_oraHelper.Connected = false;
                return(true);
            }
            catch (Exception e)
            {
                errMsg = e.Message;
                OPCLog.Error(string.Format("创建 Oracle 数据库连接时发生错误:{0}", errMsg));
                return(false);
            }
        }