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 2299
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**************@TK2MSFTNGP11.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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |