REPOST:SQL SERVER Table to XML

  • 14 years ago

    Hi All,

    Just looking for a few pointers here. I have been giving the task of pulling a table from an SQL Server, to do this, I simply created a class, and return a List (of <class>). This all works fine, now what I wish to do is find a way to irritate through this list, and generate a XML file to be used with a treeview control. The database is very simple in structure, it only has 4 fields, so the number of passes required should be minimal.

    I know that SQL Server 2005 can provide data in an XML format, however this isn't an option as It would require 2 calls to the database, as more than one thing is actually being done with the data received.

     

    I do not know if this is valid or not, but I have included my Database design specs:

     

     

    KeywordIndexID                    int                     Unchecked (Primary Key)

    Keyword                                varchar(100)     Unchecked

    PlacementBelowID                  int                     Unchecked

    DisplayComments                    bit                     Checked

     

    Basically If an Item has a PlacementBelowID of 4, then it is a subnode of the node with item 4 as the KeywordIndexID within the treeview.

     

    If anyone can offer me any pointers I would be most grateful.

    And if you need clarification on any thing I have stated here, please don’t hesitate to ask.

    Thanks

     

    P.s:

    I do not know if required, but my Class file is below

     

    Imports Microsoft.VisualBasic

    Imports Microsoft.ApplicationBlocks.Data

    Imports System.Data.SqlClient

    Imports System.Collections.Generic

     

    Namespace Keywords

        Public Class Keywords

     

            Private _KeywordIndexID As Integer

            Private _Keyword As String

            Private _PlacementBelowID As Integer

            Private _DisplayComments As Boolean

     

            Public Property KeywordIndexID() As Integer

                Get

                    Return _KeywordIndexID

                End Get

                Set(ByVal value As Integer)

                    _KeywordIndexID = value

                End Set

            End Property

     

            Public Property Keyword() As String

                Get

                    Return _Keyword

                End Get

                Set(ByVal value As String)

                    _Keyword = value

                End Set

            End Property

     

            Public Property PlacementBelowID() As Integer

                Get

                    Return _PlacementBelowID

                End Get

                Set(ByVal value As Integer)

                    _PlacementBelowID = value

                End Set

            End Property

     

            Public Property DisplayComments() As Boolean

                Get

                    Return _DisplayComments

                End Get

                Set(ByVal value As Boolean)

                    _DisplayComments = value

                End Set

            End Property

        End Class

    End Namespace

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”