给你个解决方案
递归去搜索该级是否有子级分类,如有,则继续递归搜索,如果没有则删除。
//大致的代码,自己去整理下
public Smethod(string id)
{
DataTable dt="select id from table where upid="+id;
//存在子级的
if(dt.Rows.Count>0)
{
foreach(DataRow aRow in dr.Rows)
{
//递归搜索子级
Smethod(aRow["id"].ToString());
}
}
//删除不存在的
else
{
"delete from table where id="+id;
}
}