目录树的问题,明白人过来看一下.

yihunnanzi 2009-10-13 10:17:15
access数据库里tree7表里就这3个字段:

mname(结点,字符型),pname(父结点,字符型),hz(标记,数值型)

做一个提交表单框,在这个框里输入要复制的任何节点mname,提交后,要求找到该节点上面的所有父结点,并且把这些父结点的hz+1

要求:无限级..


例如:

目前目录树的层次.

比如: CHina 下面分 北京,上海,天津,重庆 ;

北京下面分 昌平,朝阳,大兴,丰台,怀柔等..

昌平下面分 XX1,xx2,xx3,xx4,xx5,xx6,xx7,xx8

xx1下面分 ........


如果输入xx1,则把xx1上面的所有父节点,(xx1的父结点是昌平,昌平的父结点是北京,北京的父结点是china)(所以昌平,北京,china,只有这三个的hz值+1即可)

如果输入丰台,因为丰台的父结点是北京,北京的父结点是china,(只要把北京和china这两个的hz值+1即可)






麻烦给个递归代码!!谢谢!!




...全文
122 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
joking520 2009-10-13
  • 打赏
  • 举报
回复
function gethz(pname8,type8)

dim str,rs
sql="select * from [news] where mname=('"& pname8 &"')"
set rs=conn.Execute(sql)
if not rs.eof Then
conn.execute "update [news] set pzhi=pzhi+1 where mname = ('"&rs("mname")&"')"
conn.execute "update [news] set hz=hz+1 where mname = ('"&rs("mname")&"')"
rs.close '在递归以前先关闭,循环到第二次的时候,也会打开的。
set rs=nothing

gethz rs("pname"),rs("type") '递归
end if
rs.close
set rs=nothing
end function
joking520 2009-10-13
  • 打赏
  • 举报
回复
继续你昨天的代码: 如果真的是耗资源太多引起的话,这样应该可以解决

function gethz(pname8,type8)

dim str,rs
sql="select * from [news] where mname=('"& pname8 &"')"
set rs=conn.Execute(sql)
if not rs.eof Then
conn.execute "update [news] set pzhi=pzhi+1 where mname = ('"&rs("mname")&"')"
conn.execute "update [news] set hz=hz+1 where mname = ('"&rs("mname")&"')"
rs.close '在递归以前先关闭,循环到第二次的时候,也会打开的。
set rs=nothing

gethz rs("pname"),rs("type") '递归
end if
rs.close
set rs=nothing
end function


andrewsway 2009-10-13
  • 打赏
  • 举报
回复
你直接在网上搜个梅花雨tree就可以用了
yihunnanzi 2009-10-13
  • 打赏
  • 举报
回复
或者用其他思路??用数组?太复杂,我写不出来??
yihunnanzi 2009-10-13
  • 打赏
  • 举报
回复
超过110层仍然出错.麻烦高手帮我改下代码!!我要崩溃了...
  • 打赏
  • 举报
回复
就一个字符串,还用什么中括号????
function gethz(pname8,type8)

dim str,rs
sql="select pname,type,mname from [news] where mname='"& pname8 &"'"
set rs=conn.Execute(sql)

if not rs.eof Then

conn.execute("update [news] set pzhi="&type8&"+1 where mname = '"&rs("mname")&"'")
conn.execute("update [news] set hz=hz+1 where mname = '"&rs("mname")&"'")
pname88=rs("pname")
type88=rs("type")
rs.close
set rs=nothing

gethz pname88,type88 '递归

end if
rs.close
set rs=nothing
end function
yihunnanzi 2009-10-13
  • 打赏
  • 举报
回复
梅花雨我用不上..

谢谢各位,还有别的方法吗?

BlueSky4014 2009-10-13
  • 打赏
  • 举报
回复
梅花雨, 赶紧看看
kitty09_lei 2009-10-13
  • 打赏
  • 举报
回复
恩,梅花雨挺好用的
黑心 2009-10-13
  • 打赏
  • 举报
回复
帮顶。拿分。
yihunnanzi 2009-10-13
  • 打赏
  • 举报
回复
改为以下代码还是不行,和原来一样..

错误类型:
Microsoft VBScript 运行时错误 (0x800A01FB)
出现一个意外错误: 'conn.Execute'




function gethz(pname8,type8)

dim str,rs
sql="select * from [news] where mname=('"& pname8 &"')"
set rs=conn.Execute(sql)

if not rs.eof Then

conn.execute "update [news] set pzhi="&type8&"+1 where mname = ('"&rs("mname")&"')"
conn.execute "update [news] set hz=hz+1 where mname = ('"&rs("mname")&"')"
pname88=rs("pname")
type88=rs("type")
rs.close
set rs=nothing

gethz pname88,type88 '递归

end if
rs.close
set rs=nothing
end function


28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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