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

tableName:
    ProductCategory

CategoryID   自动编号
ParentCategoryID  数字
CategoryName    文本

CategoryIDParentCategoryIDCategoryName
10特色产品
20软件产品
30产品代理
41清防垢系列类
51油气井增产类
61钻井应用类
71特殊行业应用类

 

<%
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
%>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值