Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2004, 05:25 AM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying Records from 3 different SQL table.....

Hi, i am writing a Vb.net program where i want to display records from three different Sql tables of same database. suppose i have table1 with Topic, table2 with Category and table3 with Ideas. each topic has many categories and each category has many ideas. my table relationship is one-many between Ideas and Category, also one-many between Category and Topic.

my question is how do i display all these in a table on a webpage...
i would like the result to be like...
__________________________________________________ ___________________
"TOPIC 1"
__________________________________________________ ___________________
Category "1"
       Idea "1"
       Idea "2"
       idea "3"

Category "2"
       Idea "1"
       Idea "2"
       Idea "3"

category "3"
       Idea "4"
       Idea "5"
       Idea "5"
__________________________________________________ _________________
and so on.....
my main purpose is to display Category and idea but i can't seem to get the commands right.
__________________________________________________ _________________
my Topic Table has fields UID, Topic
   Category Table has UID, Category, BelongTopicUID
   Idea Table has UID, Idea, BelongCategoryUID
__________________________________________________ _________________
i hope that you all good people can help me out with this problem. i am really desperate and tried it for a long time but could not get it right. Thanking you all in Advance...

 
Old September 23rd, 2004, 07:31 AM
Authorized User
 
Join Date: Jul 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please post some code. It is difficult to help if you don't show what you have

 
Old September 24th, 2004, 01:47 AM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 Function AddTable()

        Dim i As Integer
        Dim AddTableDR As System.Data.SqlClient.SqlDataReader
        SqlConnection2.Open()
        AddTableCMD.CommandText = ("select StormCategory_1.CategoryName, StormHeading_1.Heading, StormHeading_1.Idea from StormCategory_1 INNER JOIN StormHeading_1 on StormCategory_1.uid = StormHeading_1.BelongCategoryID WHERE StormCategory_1.BelongToTopic = '" & list & "' ORDER BY StormCategory_1.CategoryName")
        AddTableDR = AddTableCMD.ExecuteReader()
        AddTableCMD = Nothing
        With AddTableDR
            Dim oldcategoryname
            If .Read Then
                Do While .Read
                    If .Item("CategoryName") <> oldcategoryname Then
                        oldcategoryname = .Item("CategoryName")
                        Dim NewRow As New TableRow
                        'New cell
                        Dim NewCell As TableCell
                        NewCell = New TableCell
                        NewCell.Text = "<b><H2>" + .Item("CategoryName") + "</H2></b>"

                        NewRow.Cells.Add(NewCell)
                        Me.Table3.Rows.Add(NewRow)
                    End If
                    Dim NewRow1 As New TableRow
                    'New cell
                    Dim NewCell1 As TableCell
                    NewCell1 = New TableCell
                    NewCell1.Text = .Item("Heading")
                    NewRow1.Cells.Add(NewCell1)
                    Me.Table3.Rows.Add(NewRow1)
                Loop
            End If
            .Close()
            AddTableDR = Nothing

        End With
        SqlConnection2.Close()
    End Function

the above is the code that i used to display two tables. but it's displaying one record less, it was suppose to 14 records but it is displaying only 13. also, this is only two tables, how do i add another table called "Comments" which has one to many relationship between Heading and Comments.
Thanks....






Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying records using asp & sql Adam H-W Classic ASP Databases 4 June 28th, 2006 08:41 AM
Displaying multiple records in Table thru Paging? InsouciantCoquette Classic ASP Databases 3 February 9th, 2006 12:14 AM
Displaying records as hyperlinks chbravo Classic ASP Databases 1 December 6th, 2005 07:38 AM
Problem displaying one of the records. mAdg3rr Classic ASP Databases 5 June 24th, 2003 08:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.