473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

SQL SERVER Table to XML

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
Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.VisualBasic
  2. Imports Microsoft.ApplicationBlocks.Data
  3. Imports System.Data.SqlClient
  4. Imports System.Collections.Generic
  5.  
  6. Namespace Keywords
  7.     Public Class Keywords
  8.         Private _KeywordIndexID As Integer
  9.         Private _Keyword As String
  10.         Private _PlacementBelowID As Integer
  11.         Private _DisplayComments As Boolean
  12.         Public Property KeywordIndexID() As Integer
  13.             Get
  14.                 Return _KeywordIndexID
  15.             End Get
  16.             Set(ByVal value As Integer)
  17.                 _KeywordIndexID = value
  18.             End Set
  19.         End Property
  20.         Public Property Keyword() As String
  21.             Get
  22.                 Return _Keyword
  23.             End Get
  24.             Set(ByVal value As String)
  25.                 _Keyword = value
  26.             End Set
  27.         End Property
  28.         Public Property PlacementBelowID() As Integer
  29.             Get
  30.                 Return _PlacementBelowID
  31.             End Get
  32.             Set(ByVal value As Integer)
  33.                 _PlacementBelowID = value
  34.             End Set
  35.         End Property
  36.         Public Property DisplayComments() As Boolean
  37.             Get
  38.                 Return _DisplayComments
  39.             End Get
  40.             Set(ByVal value As Boolean)
  41.                 _DisplayComments = value
  42.             End Set
  43.         End Property
  44.     End Class
  45. End Namespace 
Oct 23 '06 #1
1 1789
first fatch your data from the server in dataset and then wirite xml file this will be very importent work of the dataset in ADO.net. After wirite xml file u can read all records; or a perticuler records.

Create a XML file to the dataset
[HTML]
' Create a file name to write to.
Dim filename As String = "myXmlUsers.xml"

' Create the FileStream to write with.
Dim myFileStream As New System.IO.FileStream(filename, System.IO.FileMode.Create)

' Create an XmlTextWriter with the fileStream.
Dim myXmlWriter As New System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode)

' Write to the file with the WriteXml method.
objDs.WriteXml(myXmlWriter, XmlWriteMode.WriteSchema)

myXmlWriter.Close()[/HTML]


Read a XML file after Created
[HTML]Dim xmlRd As New XmlTextReader(FileName)
While (xmlRd.Read())
Select Case (xmlRd.NodeType)
Case XmlNodeType.Text

If LCase(xmlRd.Value) = LCase(UserName) Then
xmlRd.Close()
DeleteFile(FileName)
Return True
Else
If IsNumeric(xmlRd.Value) Then
intUserID = xmlRd.Value
End If
End If

End Select
End While[/HTML]
Oct 25 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
13
by: Jeager | last post by:
Why is it, Microsoft manage to write operating systems and office applications with every bell and whistle facility known to man. Yet, even after years and years of development they still cannot...
7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
21
by: lesperancer | last post by:
I've got an access97 reporting mdb that pulls data (77,000 rows) from a sql server table into a local table to run reports if the local table is part of the reporting MDB, the insert statement...
3
by: graphicssl | last post by:
Okay, so first of all, I'm a designer first and a light coder second (I'm only really trained with HTML and CSS). So I apologize for having to post about something that's probably super-trivial! ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.