Hi,
I have a database table with the following fields: id, name, parentid.
These fields are supposed to create a hierarchy for a list box, an infinite
hierarchy
Child fields of parent fields should be indented.
Root folders have a parentid of zero. Child folders in the hierarchy have
parentids that correspond
to ids. Here are some sample records of folder:
id name parentid
0 Microsoft 0
1 ABC 0
2 Oracle 1
3 Sony 1
4 AOL 3
How do I write a function to loop through this and get me the correct
hierarchy...
I'm at a loss. I loop through a data reader WHERE the parentid = 0
to start. After that, how to I loop as far as I need to return everything
in a hierarchy
something like this
------------------
------------------
--------------------
--------------------
-----------------------
--------------------
Thanks,
Do 2 2314
Check this article http://msdn.microsoft.com/library/de...us/dnsqlpro03/
html/sql03b8.asp
Sadly, if you use SQL 2000 or msde, where no "tree" functionality like
CONNECT BY, LEVELS...
in TSQL.
--
--
Dmitry Andreev. MCSD.NET
"Do" <do************ *@hotmail.com> wrote in message
news:#M******** ******@TK2MSFTN GP11.phx.gbl... Hi,
I have a database table with the following fields: id, name, parentid. These fields are supposed to create a hierarchy for a list box, an
infinite hierarchy Child fields of parent fields should be indented.
Root folders have a parentid of zero. Child folders in the hierarchy have parentids that correspond to ids. Here are some sample records of folder:
id name parentid 0 Microsoft 0 1 ABC 0 2 Oracle 1 3 Sony 1 4 AOL 3
How do I write a function to loop through this and get me the correct hierarchy... I'm at a loss. I loop through a data reader WHERE the parentid = 0 to start. After that, how to I loop as far as I need to return everything in a hierarchy something like this
------------------ ------------------ -------------------- -------------------- ----------------------- --------------------
Thanks,
Do
maybe try adding some column to the table, like PATH, by
examininh which you could easily tell where in hierarchy
specific element is. Another option is stored procedure
which loops through all elements using cursor, and returns
dataset with whatever you want <- i implemented this some
time ago, it was quite different functionality, but when
it comes to trees in ms sql, it should be easy to
customize to your problem -----Original Message----- Hi,
I have a database table with the following fields: id,
name, parentid.These fields are supposed to create a hierarchy for a
list box, an infinitehierarchy Child fields of parent fields should be indented.
Root folders have a parentid of zero. Child folders in
the hierarchy haveparentids that correspond to ids. Here are some sample records of folder:
id name parentid 0 Microsoft 0 1 ABC 0 2 Oracle 1 3 Sony 1 4 AOL 3
How do I write a function to loop through this and get me
the correcthierarchy... I'm at a loss. I loop through a data reader WHERE the
parentid = 0to start. After that, how to I loop as far as I need to
return everythingin a hierarchy something like this
------------------ ------------------ -------------------- -------------------- ----------------------- --------------------
Thanks,
Do
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Lasher |
last post by:
Hello,
I'm trying to write a tool to scrape through some of the Ribosomal
Database Project II's (http://rdp.cme.msu.edu/) pages, specifically,
through the Hierarchy Browser. (http://rdp.cme.msu.edu/hierarchy/)
The Hierarchy Browser is accessed first through a page with a form.
There are four fields with several options to be chosen from (Strain,
Source, Size, and Taxonomy) and then a submit button labeled "Browse".
The HTML of the form is...
|
by: SBurrs |
last post by:
Is it possibe to refer to a folder in the web root in a 'standard'
way?
What I mean is, I know that "../" means look at the directory/folder
one up from where you are.
What I am trying to do is create web pages that refer to an image in a
directory. Since the pages from which the reference come from may be
more than one or two directories deep, using "../" or others may not
work. I am also trying to have only one "img" folder that I can...
|
by: scott |
last post by:
I'm creating a tree menu that uses FSO to read folders, subfolders and
files. I'd like for each folder to have capabilty of being either Level
1,2,3,4 or 5 security. The 5 Levels are my security levels with 5 being
Admin.
I'm looking for any advice on how to go about this. I was thinking of
creating a hidden text file within each folder and storing the folders
security level in it, then let asp read the text file as it builds my tree...
|
by: Yaro |
last post by:
Hi All
(UDB 8.1 FP8, Win)
In my simple test database, I have two tables
CREATE TABLE "DB2ADMIN"."AAA" (
"F1" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
"F2" VARCHAR(10),
PRIMARY KEY ("F1")
)
|
by: Ed West |
last post by:
Hello,
I am wondering about best practices for class hierarchies and using
ADO.Net, especially the DataSet update/delete commands and the data
relations... this needs to package/unpackage to xml for client/server
sending. The class properties pretty much correspond to database tables.
This is a pretty long question so thanks in advance for reading and
commenting!
| |
by: HalcyonWild |
last post by:
I did try to search this in old posts, but could not find it.
I suppose it is ok to ask beginner level questions here, unlike other
groups, demarcated for beginners and experts.
Suppose I create a class in a namespace, MyNamespace.Trials.
Now, should I create a folder on the disk, like
c:\csprogs\MyNamespace\Trials and keep the generated files there. Or I
can keep them anywhere on the disk.
|
by: azs0309 |
last post by:
Hi all,
I don't know i would able to explain my problem or not. I have a hierarchy tables and i want to duplicate those hierarchy tables into other database. I tried loading data with export and import. but what i have seen after importing the data is the nullability characteristics of some columns are lost..i.e in original tables they were not null and now they are null(i did "describe table" both the sides). then i used db2look to generate...
|
by: Andrew Meador |
last post by:
I have searched and found where this has been discussed, but the
suggestions I have found have all ended up tuning into debated about
whether it needs to be done - but - as far as I can tell - I need to.
I am trying to setup a database that tracks parcel history. I want
to be able to choose a parcel and see a list of its children (smaller
pieces to the property that have been sold off) and a list of its
parents (previous tracts/parcels...
|
by: evenlater |
last post by:
I have an Access application on a terminal server. Sometimes my users
need to export reports to pdf, rtf or xls files and save them to their
own client device hard drives.
They can do that right now the way I have this set up, but it's
confusing and slow. When they browse for a place to save the reports,
they see all of the drives on the terminal server as well as their own
client drives. So they're likely to want to choose "My...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |