递归执行出错
我写了一个递归函数取部门名称:
function crtdep(fdep)
set frs=Server.CreateObject("ADODB.Recordset")
fsql="select deptcde,deptname,parentdep from t_com_deptment where parentdep='"&fdep&"'"
frs.open fsql,conn,1,1
do while not frs.eof
response.write " "&frs("deptname")
crtdep frs("deptcde")
frs.movenext
loop
frs.close
set frs=nothing
end function
crtdep("2")
但是执行出错:
---------------------------------------------------
Microsoft VBScript 运行时错误 错误 '800a01fb'
出现一个意外错误: 'frs.Open'
/apps/sysmgr/deptment/deeptree.asp,行34
问题点数:20、回复次数:3Top
1 楼hj3793(白开心)回复于 2006-02-20 20:45:55 得分 20
'数据库打开没有关闭
-----------------------------
Dim myArray(0)
Dim iMax
Dim iRecordCount
function crtdep(fdep)
set frs=Server.CreateObject("ADODB.Recordset")
fsql="select deptcde,deptname,parentdep from t_com_deptment where parentdep='"&fdep&"'"
frs.open fsql,conn,1,1
iMax = Ubound(myArray)
iRecordCount = frs.RecordCount
ReDim myArray(iMax + iRecordCount)
do while not frs.eof
myArray(iMax + 1) = frs("deptname")
frs.movenext
loop
frs.close
set frs=nothing
For i = iMax + 1 to iMax+iRecordCount
crtdep myArray(i)
Next
end functionTop
2 楼dengfvip(丘吉归来)回复于 2006-02-21 09:06:09 得分 0
不知道怎么回事,同样的代码我在另外一台电脑上又可以正常运行?
搞不懂了!Top
3 楼dengfvip(丘吉归来)回复于 2006-02-21 09:45:41 得分 0
原因找到,是数据有问题,陷入死循环Top




