ASP tree Diagram generation program (source code) for connecting to the database
Source: Internet
Author: User
<% ' *****************************
' ******* connection Database tree Graph generator ********
'*****************************
' Suppose you have established the SQL Server database Unittree and created tables in the library:
' Units (ID Unit ordinal integer unique, name unit name string, upid parent unit ordinal number integer)
' Note: Upid=0 indicates that the unit is a root node unit;
' Enter some data such as: (1,aa,0) (2,aabb,1) (3,aacc,1) (4,aabb11,2)
' For the following program test.
%>
<% ' Establish a database connection
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Provider=sqloledb;data source=yoursrcname;user id=sa;password=;d atabase=unittree"
%>
<% ' Sub process: Spanning Tree Touzi node data
Sub TreeNode (Code)
sqlunit= "Select Id,name" &_
"From Units" &_ "where upid=" &Code& "" &_
"ORDER by ID"
Set Rsunit=conn. Execute (Sqlunit)
Do as not rsunit.eof
Response.Write ("Node" &rsunit ("ID") & "=appendchild" ("&" Node "&Code&", Foldernode ("" &rsunit ( "Name") & "', '" &rsunit ("ID") & "', 0)" &CHR (10))
Call TreeNode (Rsunit ("ID"))
Rsunit.movenext
Loop End Sub
%>
<HTML>
<HEAD>
<title> Drill Analysis </title>
<script language= "JavaScript" >
/****************************** Generating tree Graph Data *********************************/
function Generatetree ()
{
Generating Tree Graph Data
-----VBScript-----
<%
' Display units
sqlunit0= "Select Id,name" &_
"From Units" &_
"Where Upid=0" &_
"ORDER by ID"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.