卡不能看这个递归算法有什么错,怎末执行不了啊

yan717fang 2009-06-11 04:33:30
private void del(string id) //id参数为选择删除的节点 {
int i;
string sql1,sql2;
sql1="select depid from dep where parent_id='"+id+"'"; //选择出节点id的所有子结点的depa_id
DataSet ds = SqlHelper.ExecuteDataSet(sql1);
if(ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
{
for(i=0;i<ds.Tables[0].Rows.Count;i++)
del(ds.Tables[0].Rows[i]["depid"].ToString()); //删子结点
}
sql2="delete from dep where dep_id='"+id+"'"; //删除4
SqlHelper.ExecuteNoQueryString(sql2);//删当前结点

}
...全文
20 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yan717fang 2009-06-11
  • 打赏
  • 举报
回复
呵呵呵 就是
yan717jie 2009-06-11
  • 打赏
  • 举报
回复
其实都正确,在好好检查一下是不是其他的地方有问题
duzhonghua 2009-06-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 raineo 的回复:]
private void del(string id)  //id参数为选择删除的节点      {
int  i;
string  sql1,sql2;
sql1="select  depid  from  dep  where  parent_id='"+id+"'"; //选择出节点id的所有子结点的depa_id
DataSet ds = SqlHelper.ExecuteDataSet(sql1);
if(ds.Tables.Count>0  &&  ds.Tables[0].Rows.Count>0)
{
for(i=0;i <ds.Tables[0].Rows.Count;i++)
del(ds.Tables[0].Rows[i]["depid"].ToString());      //删子结点
}…
[/Quote]
支持,下次记得把错误信息一起带上
zenowolf 2009-06-11
  • 打赏
  • 举报
回复
private void del(string id) //id参数为选择删除的节点 {
int i;
string sql1,sql2;
sql1="select depid from dep where parent_id='"+id+"'"; //选择出节点id的所有子结点的depa_id
DataSet ds = SqlHelper.ExecuteDataSet(sql1);
if(ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
{
for(i=0;i <ds.Tables[0].Rows.Count;i++)
del(ds.Tables[0].Rows[i]["depid"].ToString()); //删子结点
}
else return;
sql2="delete from dep where dep_id='"+id+"'"; //删除4
SqlHelper.ExecuteNoQueryString(sql2);//删当前结点

}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧