ASP - arbol en asp no me funciona si parent es texto

   
Vista:

arbol en asp no me funciona si parent es texto

Publicado por necora01 (1 intervención) el 06/10/2009 12:24:37
De principio estoy empezando en esto de asp por lo que ser pacientes conmigo por favor. He encontrado un árbol basado en omentree. la BBDD tiene los campos text (para el nombre) key (para el usuario) y parent (para identificar el padre). necesito que el campo parent y key no sean numericos sino texto. si los cambio no me funciona el codigo he intentado revisar y poner ' en varios sitios porque se supone que tendría que decirle a las consultas que es texto pero no consigo resultados ¿me podeis ayudar? (pongo cacho de codigo que creo que está mal):
<%@ Language=VBScript %>
<%
Function nodelist(parent)
SQLStmt = "SELECT key, parent, text FROM Nodes WHERE parent=" & parent & ""
Set RS = Connection.Execute(SQLStmt)
Do While Not RS.EOF
tempID = RS("parent")
If tempID = 0 Then tempID = 1
Set RSTemp = Connection.Execute("SELECT key, parent, text FROM Nodes WHERE parent=" & RS("key"))
If RSTemp.EOF = False Then
If RS("parent") = 0 Then 'this one's directly below the Root
txtjscript = "treeData.add(new FolderNode(""_" & Trim(RS(0)) & """,""root"",""" & Trim(RS(2)) & ""","""","""",""page2.asp?nodeId=" & RS(0) & """," & RS(0) & "));"
Else
txtjscript = "treeData.add(new FolderNode(""_" & Trim(RS(0)) & """,""_" & RS(1) & """,""" & Trim(RS("text")) & """,""img-folder-closed-1.gif"",""img-folder-open-1.gif"",""page2.asp?nodeId=" & RS(0) & """," & RS(0) & "));"
End If
Else
If RS("parent") = 0 Then 'this one's directly below the Root
txtjscript = "treeData.add(new FolderNode(""_" & Trim(RS(0)) & """,""root"",""" & Trim(RS(2)) & """,""img-folder-closed-fav.gif"",""img-folder-closed-fav.gif"",""page2.asp?nodeId=" & RS(0) & """," & RS(0) & "));"
Else
txtjscript = "treeData.add(new LinkNode(""_" & RS(1) & """,""" & Trim(RS(2)) & """,""page2.asp?nodeId=" & RS(0) & ""","""",""img-page.gif""," & RS(0) & "));"
End If
End If
Mainjscript = Mainjscript & txtjscript & vbCrLf
Set RSTemp = Nothing
xNodes = xNodes + 1
nodeindent = nodeindent + 1
nodelist RS(0)
nodeindent = nodeindent - 1
If xNodes >= nNodes Then 'Just to be on the save side
Exit Do
Exit Function
End If
RS.MoveNext
Loop
End Function
Dim nodeindent, nNodes, Mainjscript
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tree.mdb")
Set RSnNodes = Connection.Execute("SELECT Count(Nodes.Key) AS nId FROM Nodes")
nNodes = RSnNodes("nId")
Set RSnNodes = Nothing
targetFrame = "pageFrame"
nodelist 0
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
<title>Isis</title>
<script language="javascript" type="text/javascript">
<!-- Begin Hiding
function start() {
loadData();
drawTree();
}
function drawTree() {
outputFrame = top.treeFrame.window.document;
outputFrame.open("text/html");
outputFrame.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
outputFrame.write("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \">\n");
outputFrame.write("
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
\n");
outputFrame.write("
<head>
\n");
/*
Netscape 4.7* seems to reload the frame when a character set is specified!??
outputFrame.write("
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
\n");
*/
outputFrame.write("
<meta http-equiv=\"Expires\" content=\"0\" />
\n");
outputFrame.write("
<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />
\n");
outputFrame.write("
<meta http-equiv=\"Pragma\" content=\"no-cache\" />
\n");
outputFrame.write("
<link rel=\"stylesheet\" type=\"text/css\" href=\"tree.css\" media=\"screen\" />
\n");
outputFrame.write("
</head>
\n");
outputFrame.write("
<body bgcolor=\"" + backgroundColor + "\" background=\"" + backgroundImage + "\" link=\"" + linkColor + "\" alink=\"" + aLinkColor + "\" vlink=\"" + vLinkColor + "\">
\n");
outputFrame.write("<form name=\"Form\">\n");
outputFrame.write("<font face=\"" + omenTreeFont + "\" size=\"" + omenTreeFontSize + "\" color=\"" + textColor + "\">\n");
outputFrame.write(prefixHTML + "\n<nobr>\n");
if (treeData[1].target == "") {var targetFrame = defaultTargetFrame} else {var targetFrame = treeData[1].target}
drawBranch("root","");
outputFrame.write("</nobr>\n" + suffixHTML + "\n");
outputFrame.write("</font>\n</form>\n
</body>
\n
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder