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