コード例 #1
0
        /// <summary>
        /// Runs a given set of Sql for the purpose of getting the returned list
        /// </summary>
        private void RunListSql()
        {
            DateTime started           = DateTime.Now;
            TimeSpan maxWait           = new TimeSpan(0, 1, 0);
            int      _returnedRowCount = 0;

            items    = new ArrayList();
            AllItems = null;

            OracleConnection connection = new OracleConnection(_dbConnectionString);
            OracleDataReader reader;

            if (_configString != null)
            {
                OracleCommand oConfigCommand = new OracleCommand(_configString, connection);
                connection.Open();
                oConfigCommand.ExecuteNonQuery();
                OracleCommand oCommand = new OracleCommand(ListSql, connection);
                reader = oCommand.ExecuteReader();
            }
            else
            {
                OracleCommand oCommand = new OracleCommand(ListSql, connection);
                connection.Open();
                reader = oCommand.ExecuteReader();
            }
            try
            {
                while (reader.Read())
                {
                    _returnedRowCount++;

                    string sValue = DataAccess.GetStringFromDataType(reader.GetDataTypeName(0), 0, reader);
                    items.Add(sValue);

                    AllItems += sValue + " ";

                    // Want to make sure we don't get stuck here, so use a default timeout
                    if (DateTime.Now - started > maxWait)
                    {
                        connection.Close();
                        throw new ApplicationException(String.Format("Times out collecting records for this query: {0} after {1} seconds.", ListSql, maxWait.Seconds));
                    }
                }
                if (AllItems != null)
                {
                    // remove final space
                    AllItems = AllItems.Substring(0, AllItems.Length - 1);
                }
            }
            finally
            {
                reader.Close();
            }


            _affectedRowCount = _returnedRowCount;
            ListSql           = null;
        }