473,706 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL - a menu system - plz help

Hi,

As subj says. A simple menu is defined in a table. But how to extract it?
Heres the deal:

Table menu has these 3 columns: menuid parent menudesc

Ok this should be easy right? Those menu-rows that has parent=0 is
"toplevel". And so forth. An example:

1 0 "Items"
2 0 "Standings"
3 0 "Test"
4 2 "Liverpool"
5 2 "AC Milan"
6 1 "Itemno1"

This menu should in layout come in this order:

Items
Itemno1
Test
Standings
AC Milan
Liverpool

That is: Alphabetically sorted and with the children underneath the parents.
Right? Yes - and selecting the menu and doing some gymnastics in ASP isnt
that hard. But ASP must be the language that has the "crapiest" way of
handling arrays...so a simple task is really messy. Creating a stored
procedure involes 2-3 temporary tables as I see it. Not vey elegant either.

So my question is: Isnt there any way of selecting this order directly using
SQL?? Some nice clean and beautiful way?

--
Thanks,
Summa
Jul 20 '05 #1
2 1512
Hi

Have you thought of using XML for this?

http://sqlxml.org/faqs.aspx?faq=53

You may also want to search Google for hierarchy and SQLServer

If you want a permanent reference you can try the following books:
Advanced Transact-SQL for SQL Server 2000 by Itzik Ben-Gan and Tom Moreau.
The book has an entire chapter on modeling a hierarchical structure in SQL
Server, along with T-SQL to implement the same.

SQL for Smarties by Joe Celko. This has an alternative method of modeling
trees in an RDBMS.

John

"Summasumma rum" <Su***********@ hotmail.com> wrote in message
news:3f******** *************@d text02.news.tel e.dk...
Hi,

As subj says. A simple menu is defined in a table. But how to extract it?
Heres the deal:

Table menu has these 3 columns: menuid parent menudesc

Ok this should be easy right? Those menu-rows that has parent=0 is
"toplevel". And so forth. An example:

1 0 "Items"
2 0 "Standings"
3 0 "Test"
4 2 "Liverpool"
5 2 "AC Milan"
6 1 "Itemno1"

This menu should in layout come in this order:

Items
Itemno1
Test
Standings
AC Milan
Liverpool

That is: Alphabetically sorted and with the children underneath the parents. Right? Yes - and selecting the menu and doing some gymnastics in ASP isnt
that hard. But ASP must be the language that has the "crapiest" way of
handling arrays...so a simple task is really messy. Creating a stored
procedure involes 2-3 temporary tables as I see it. Not vey elegant either.
So my question is: Isnt there any way of selecting this order directly using SQL?? Some nice clean and beautiful way?

--
Thanks,
Summa

Jul 20 '05 #2
John Bell wrote:
Hi

Have you thought of using XML for this?

http://sqlxml.org/faqs.aspx?faq=53

You may also want to search Google for hierarchy and SQLServer


Very nice links...thatnks .

/Summa
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3273
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help with this problem. I am uncertain about what etiquette calls for, but more on that later. My Objective: I am trying to control the _VMWare Desktop_ application
4
3068
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped up, the window does not closes until I click on the window. Below is the code. Hopefully, you can help me out.
7
2695
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote server returned an error: (500) Internal Server Error." I found a post that suggested to catch the WebException to retrieve the actual HttpWebResponse object for more information. The response returned is shown below. At first I thought this was a...
2
1337
by: Peter Proost | last post by:
Hi, I've got the following ownerdraw menu: drag a mainmenu on a form and add some menuitems to it, set all the menuitems to ownerdraw = true and for every menuitem add this code (replace nothing with an ico if you want to show an icon in the menu) also add a module and copy paste the code at the bottom of the message. Private Sub MenuItem1_DrawItem1(ByVal sender As Object, ByVal e As _
4
4143
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get context help with that particular command. In VB6 this was easy, since each menu item had a "helpId" property. That doesn't seem to be the case in VB.NET. Am I wrong about that, or (alternatively) is there some other way to accomplish this? --
3
2110
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can anyone recommend how to get started? Is there an Ajax control available for this or would more a basic javascript work just as well. I'm assuming I just need a div element that is shown on a mouse over, but I'm not sure how to go about aligning all...
0
1541
by: Patel | last post by:
Hi All, I am doing one INTERESTING work with Context Menu Strip. I am trying to insert a custom control / .Net control in Context menu as a context menu strip. I tried inserting MonthCalender in Context Menu as a context menu strip, it worked. Now, i tried same with Windows Media Player ( a control available in C#.Net). But I'm not able to set its URL property (i.e. path of the media file). and i'm getting the exception like...
1
14322
by: Preeti | last post by:
Hi all I am a fresher and have been given a requirement in VB.net I have to make an application in VB.net which will run as a system tray icon and will add one or two items in the default windows right clink context menu. on clicking on that menu item the application should write a signature on the current cursor position
1
3745
by: bruce628 | last post by:
I want to use SWT Label and popmenu to construct a menubar ,and the effect of this menubar is same to the menubar in SWT.When click the Label,it should be highlighted and popmenu shows.The issue is when click the label and move the mouse to enter next label,the next label can not be highlighted.Can anyone have a solution for it? Here is my code: import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.*; public class labelmenu { ...
0
8781
marktang
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...
0
8697
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,...
0
9286
Oralloy
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...
0
9156
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8997
tracyyun
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...
0
7911
agi2029
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...
1
6615
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3149
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
3
2095
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.