未处理的类型' System.StackOverflowException'发生在Oracle.DataAccess.dll中

时间:2015-02-25 14:43:11

标签: c# c#-4.0 oracle11g stack-overflow

我使用Oracle.DataAccess(4.112.3.0)库查询Oracle数据库版本11.2.0.1.0但是在几次请求后我在command.executeReader上出现此错误: 未处理的类型' System.StackOverflowException'发生在Oracle.DataAccess.dll

public List<Item> GetChildCategories(Int64 p_itemId = 0)
        {
            List<Item> result = new List<Item>();
            if (p_itemId == 0)
            {
                return result;
            }

             // sql query
            OracleCommand command = this.connection.CreateCommand();
            //command.Transaction = transaction;

            command.CommandText = "select i2.item itemFound, i2.item_id itemIdFound " +
                                    "from items i, item_relations r, items i2 " +
                                    "where r.parent_item_id = i.item_id " +
                                    "and i2.item_id = r.child_item_id " +
                                    "and i2.org_id = r.org_id " +
                                    "and i2.org_id = 1 " +
                                    "and i2.org_id = i.org_id " +
                                    "and i2.item_type_id not in (4,5,6,10,3) " +
                                    "and i.item_id = " + p_itemId + " " +
                                    "and i2.UNDER_CONSTRUCTION is null " +
                                    "order by i2.item";

            OracleDataReader reader = command.ExecuteReader(); // error on the execute reader
            while (reader.Read())
            {
                string item = reader["itemFound"] == DBNull.Value ? string.Empty : (string)reader["itemFound"];


                Int64 item_id;
                if (Int64.TryParse(reader["itemIdFound"].ToString(), out item_id))
                {

                }

                result.Add(new Item(item, item_id, p_itemId));
            }

            reader.Close();
            reader.Dispose();

            return result;
        }

我从递归函数中调用它。

private void WriteExcelLine(Int64 p_itemId, int p_colId)
        {
            int colId = p_colId;
            colId++;

            List<Item> itemsList = OraConnection.GetChildCategories(p_itemId);
            foreach (Item item in itemsList)
            {
                worksheet1.Cells[rowId, colId].Value = item.ItemName;

                rowId++;  

                WriteExcelLine(item.ItemId, colId);
            }

            if (itemsList.Count() == 0)
            {
                colId--;
            }            
        }

你有什么想法吗?谢谢!

0 个答案:

没有答案