利用递归获得无限分类的父类名称getParentCategoryFullName

王朝厨房·作者佚名  2007-01-05
窄屏简体版  字體: |||超大  

摘要:利用递归获得无限分类的父类名称getParentCategoryFullName

tableName:

ProductCategory

CategoryID 自动编号

ParentCategoryID 数字

CategoryName 文本

CategoryID

ParentCategoryID

CategoryName

1

0

特色产品

2

0

软件产品

3

0

产品代理

4

1

清防垢系列类

5

1

油气井增产类

6

1

钻井应用类

7

1

特殊行业应用类

<%

function getParentCategoryFullName(CategoryID,conn,FullName)

if CategoryID=0 then

getParentCategoryFullName="无父类"

exit function

end if

Set rs1=Server.CreateObject("ADODB.Recordset")

strSQL="SELECT CategoryName,ParentCategoryID FROM ProductCategory WHERE CategoryID=" & CategoryID

rs1.Open strSQL,conn,1,1

tmpID=rs1.fields(1).value

tmpName=rs1.fields(0).value

rs1.close

set rs1=nothing

if FullName<>"" then

FullName= tmpName & "-" & FullName

else

FullName=tmpName

end if

if tmpID<>0 then

FullName=getParentCategoryFullName(tmpID,conn,FullName)

end if

getParentCategoryFullName=FullName

end function

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航