数据库结构 ID Role //节点值 Class //节点层[根节点为0] ParentID //父节点[无父节点为NULL]<% Dim iCount_0,iCount_1,iCount_2,iCount_3 iCount_0="1" Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='1'" Set Session("DataCmd").ActiveConnection=Session("DataConn") Set Rs_Count=Session("DataCmd").Execute If Not Rs_Count.Eof Then iCount_1=Rs_Count(0) End If Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='2'" Set Session("DataCmd").ActiveConnection=Session("DataConn") Set Rs_Count=Session("DataCmd").Execute If Not Rs_Count.Eof Then iCount_2=Rs_Count(0) End If Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='3'" Set Session("DataCmd").ActiveConnection=Session("DataConn") Set Rs_Count=Session("DataCmd").Execute If Not Rs_Count.Eof Then iCount_3=Rs_Count(0) End If Dim TableRow,TableCol TableRow=4 TableCol=CInt(iCount_0)*CInt(iCount_1)*CInt(iCount_2)*CInt(iCount_3) Rem Response.Write iCount_0&"|"&iCount_1&"|"&iCount_2&"|"&iCount_3&"<br>" Response.Write "<table border='0' cellpadding='0' cellspacing='0' width='80%'>" For iRow=1 To TableRow Response.Write "<tr>" For iCol=1 To TableCol Response.Write "<td>" Rem 算法有些问题开始??? Session("DataCmd").CommandText="select * from ManageStruct where Class='"&CStr(iRow-1)&"' And ParentID='"&Cstr(iCol)&"'" Rem 算法有些问题结束 Set Session("DataCmd").ActiveConnection=Session("DataConn") Set Session("rs_main")=Session("DataCmd").Execute If Not Session("rs_main").Eof Then Response.Write "<table border='0' cellpadding='0' cellspacing='0' width='100%'>" Response.Write "<tr>" Response.Write "<td width='33%'> </td>" Response.Write "<td width='33%'> </td>" Response.Write "<td width='34%'> </td>" Response.Write "</tr>" Response.Write "<tr>" Response.Write "<td width='33%'> </td>" Response.Write "<td width='33%' bgcolor='#8CAADC'>"&Session("rs_main")("Role")&"</td>" Response.Write "<td width='34%'> </td>" Response.Write "</tr>" Response.Write "<tr>" Response.Write "<td width='33%'> </td>" Response.Write "<td width='33%'> </td>" Response.Write "<td width='34%'> </td>" Response.Write "</tr>" Response.Write "</table>" Else Response.Write " " End If Response.Write "</td>" Next Response.Write "</tr>" Next Response.Write "</table>" %>
ID
Role //节点值
Class //节点层[根节点为0]
ParentID //父节点[无父节点为NULL]<%
Dim iCount_0,iCount_1,iCount_2,iCount_3
iCount_0="1"
Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='1'"
Set Session("DataCmd").ActiveConnection=Session("DataConn")
Set Rs_Count=Session("DataCmd").Execute
If Not Rs_Count.Eof Then
iCount_1=Rs_Count(0)
End If
Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='2'"
Set Session("DataCmd").ActiveConnection=Session("DataConn")
Set Rs_Count=Session("DataCmd").Execute
If Not Rs_Count.Eof Then
iCount_2=Rs_Count(0)
End If
Session("DataCmd").CommandText="select Count(Class) from ManageStruct where Class='3'"
Set Session("DataCmd").ActiveConnection=Session("DataConn")
Set Rs_Count=Session("DataCmd").Execute
If Not Rs_Count.Eof Then
iCount_3=Rs_Count(0)
End If
Dim TableRow,TableCol
TableRow=4
TableCol=CInt(iCount_0)*CInt(iCount_1)*CInt(iCount_2)*CInt(iCount_3)
Rem Response.Write iCount_0&"|"&iCount_1&"|"&iCount_2&"|"&iCount_3&"<br>"
Response.Write "<table border='0' cellpadding='0' cellspacing='0' width='80%'>"
For iRow=1 To TableRow
Response.Write "<tr>"
For iCol=1 To TableCol
Response.Write "<td>"
Rem 算法有些问题开始???
Session("DataCmd").CommandText="select * from ManageStruct where Class='"&CStr(iRow-1)&"' And ParentID='"&Cstr(iCol)&"'"
Rem 算法有些问题结束
Set Session("DataCmd").ActiveConnection=Session("DataConn")
Set Session("rs_main")=Session("DataCmd").Execute
If Not Session("rs_main").Eof Then
Response.Write "<table border='0' cellpadding='0' cellspacing='0' width='100%'>"
Response.Write "<tr>"
Response.Write "<td width='33%'> </td>"
Response.Write "<td width='33%'> </td>"
Response.Write "<td width='34%'> </td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td width='33%'> </td>"
Response.Write "<td width='33%' bgcolor='#8CAADC'>"&Session("rs_main")("Role")&"</td>"
Response.Write "<td width='34%'> </td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td width='33%'> </td>"
Response.Write "<td width='33%'> </td>"
Response.Write "<td width='34%'> </td>"
Response.Write "</tr>"
Response.Write "</table>"
Else
Response.Write " "
End If
Response.Write "</td>"
Next
Response.Write "</tr>"
Next
Response.Write "</table>"
%>