首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

有个递归算法,为什么同一级只能取一条记录?该怎么处理

2012-01-03 
有个递归算法,为什么同一级只能取一条记录?subGetSubTree()myCommand1NewOleDb.OleDbCommand( selectcat

有个递归算法,为什么同一级只能取一条记录?
sub   GetSubTree()
              myCommand1   =   New   OleDb.OleDbCommand( "select   categoryID,categoryName   from   category   where   parentCategoryid= ' "   &   categoryID   &   " '   and   categoryclass= 'category '   and   [language]= ' "   &   radioLanguage.SelectedItem.Value   &   " '   order   by   myorder ",   myConnection)
                myDataReader1   =   myCommand1.ExecuteReader
                Do   While   myDataReader1.Read()
                        dropdownParentID.Items.Add(New   ListItem(strT   &   "├   "   &   Trim(myDataReader1.Item( "categoryName ")).Replace( "  ",   "   "),   myDataReader1.Item( "categoryID ")))
                        getSubTree(myDataReader1.Item( "categoryID "))
                Loop
end   sub

每次循环,先把记录加到一个dropdownlist里,然后对这条记录再递归,取出它所有的子节点,然后再子节点再递归....但要命的是为什么每一层只取第一条记录?即递归调用后没有返回?还是因为用了同一个mydatareader1?


[解决办法]
string str= "Name = "+ " ' "+textBox.text+ " ' ";
DataRow[] foundRows;
foundRows = myDataSet.Tables[ "myDataTable "].Select(str);

热点排行