473,407 Members | 2,312 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,407 software developers and data experts.

Otaining Data as XML from SQL Server

Hi guys 'n' girls,
I tried to obtain data from SQL Server by using the "FOR XML AUTO, ELEMENTS"
clause and executing the SQLCommand with the ExecuteXmlReader() method.

My queries will not return very much data, but the data which they return
may change often.

I have a class which manages all the database stuff and it should return an
XPathDocument. As this class has a constructor with an XmlReader parameter, I
thought this could work great, but the data returned has no root node, so I
have a problem, as the XPathDocument will only contain the first node.

Can anyone give me a solution on how to get the data into a XPathDocument
object? All connections to the database should be closed before I return the
XPathDocument object to the caller.

I hope this was somehow clear and someone can provide a solution.

Thanks a lot...

Florian
Nov 17 '05 #1
1 1265
Florian,

It seems like all of the modes you have (AUTO, EXPLICIT, PATH) will not
return true XML documents, but the elements themselves. If you want to
process these, I would recommend getting the results as a string (I believe
you can just call ExecuteScalar and it will return the string for you) and
then wrapping it in an element that can serve as the document root.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stampede" <St******@discussions.microsoft.com> wrote in message
news:A0**********************************@microsof t.com...
Hi guys 'n' girls,
I tried to obtain data from SQL Server by using the "FOR XML AUTO,
ELEMENTS"
clause and executing the SQLCommand with the ExecuteXmlReader() method.

My queries will not return very much data, but the data which they return
may change often.

I have a class which manages all the database stuff and it should return
an
XPathDocument. As this class has a constructor with an XmlReader
parameter, I
thought this could work great, but the data returned has no root node, so
I
have a problem, as the XPathDocument will only contain the first node.

Can anyone give me a solution on how to get the data into a XPathDocument
object? All connections to the database should be closed before I return
the
XPathDocument object to the caller.

I hope this was somehow clear and someone can provide a solution.

Thanks a lot...

Florian

Nov 17 '05 #2

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

Similar topics

2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
5
by: B1ackwater | last post by:
We've fooled around with Access a bit, but only using the single-user store-bought version. It seems to be a good database - versatile and infinitely programmable - and can apparently be used as a...
5
by: Yossarian | last post by:
I have a handheld running CE .NET 4.2 and I am using c# with framework 1.1 to develop a solution for syncing data that is on the handheld with the local pc. Our handheld cradles only support...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
3
by: sammyloo | last post by:
Hi all, I'm experiencing a problem using ASP.NET web services to access a different server with SQL Server 2000 database. And I get the error of the following Exception Details:...
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...
7
by: David | last post by:
i think i just realized i'm an idiot. again. (not syntactically correct code... just pieces to illustrate) class StateObject { members like socket, receiveBuffer, receiveBufferSize,...
1
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
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
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,...
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
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.