473,789 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ExecuteXmlReade r w/ Multiple result sets from SP

I have an sp that outputs multiple xml fragments w/ no root. The sp calls
individual sp's to output the correct set of data and each "type" has
different fields.

ex.:
<LEADERBOARD @Type='Rushing' >
<LEADER @Carries=''/>
</LEADERBOARD>
<LEADERBOARD @Type='QBRating '>
<LEADER @Rating='' @CompletionPct= ''/>
</LEADERBOARD>
<LEADERBOARD @Type='Tackles' >
<LEADER @Assisted='' @Tackles='' @Total=''/>
</LEADERBOARD>

I need to take the output and use XSLT to translate it to custom output. But
no matter what I try I hit a dead end. Following is what I have tried.
1)
CREATE PROCEDURE GetAllLeaders_X ML
@Param1, @Param2, @Param3
AS

SET NOCOUNT ON

SELECT '<LEADERBOARDS> '
EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3
SELECT '</LEADERBOARDS>'

GO

with the following code (C#):
XmlReader rdrXml = cmdXML.ExecuteX mlReader();

or this:

DataSet dsXML = new DataSet();

dsXML.ReadXml(c mdXML.ExecuteXm lReader(), XmlReadMode.Fra gment);

result: "Invalid command sent to ExecuteXmlReade r(). The command must return
an XML result.
2) If I remove the "root" LEADERBOARDS from before and after the sp's:

with the same code (C#)
(see #1 above)

result: "Object reference not set to an instance of an object. "

(btw. It doesn't matter if I use "ROOT" or "LEADERBOAR DS" as the root
element).

I have looked at SqlXmlCommand but I don't see how I can add multiple
parameters to pass to the sp. So if anyone can point me in the right
direction or provide me with some sample code to that effect I'd appreciate
any help. Even if only to let me know if I could get a better answer from
another ng. Everything I have tried works fine w/ other sp's that return a
single, well-formed frament w/ a root element. I need help ASAP,
PLEEEEAASSSEEEE EE!
Nov 11 '05 #1
3 7738
Inside those stored procedures - you are doing "for xml" on the select
statements??
"Mark Miller" <no**********@w aveshift.com> wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl...
I have an sp that outputs multiple xml fragments w/ no root. The sp calls
individual sp's to output the correct set of data and each "type" has
different fields.

ex.:
<LEADERBOARD @Type='Rushing' >
<LEADER @Carries=''/>
</LEADERBOARD>
<LEADERBOARD @Type='QBRating '>
<LEADER @Rating='' @CompletionPct= ''/>
</LEADERBOARD>
<LEADERBOARD @Type='Tackles' >
<LEADER @Assisted='' @Tackles='' @Total=''/>
</LEADERBOARD>

I need to take the output and use XSLT to translate it to custom output. But no matter what I try I hit a dead end. Following is what I have tried.
1)
CREATE PROCEDURE GetAllLeaders_X ML
@Param1, @Param2, @Param3
AS

SET NOCOUNT ON

SELECT '<LEADERBOARDS> '
EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3
SELECT '</LEADERBOARDS>'

GO

with the following code (C#):
XmlReader rdrXml = cmdXML.ExecuteX mlReader();

or this:

DataSet dsXML = new DataSet();

dsXML.ReadXml(c mdXML.ExecuteXm lReader(), XmlReadMode.Fra gment);

result: "Invalid command sent to ExecuteXmlReade r(). The command must return an XML result.
2) If I remove the "root" LEADERBOARDS from before and after the sp's:

with the same code (C#)
(see #1 above)

result: "Object reference not set to an instance of an object. "

(btw. It doesn't matter if I use "ROOT" or "LEADERBOAR DS" as the root
element).

I have looked at SqlXmlCommand but I don't see how I can add multiple
parameters to pass to the sp. So if anyone can point me in the right
direction or provide me with some sample code to that effect I'd appreciate any help. Even if only to let me know if I could get a better answer from
another ng. Everything I have tried works fine w/ other sp's that return a
single, well-formed frament w/ a root element. I need help ASAP,
PLEEEEAASSSEEEE EE!

Nov 11 '05 #2
If you are referring to the statments:
SELECT '<LEADERBOARDS> '
and
SELECT '</LEADERBOARDS>'

no, I am not. I was not aware that was possible. Won't that wrap the text
"<LEADERBOARDS> " in another XML tag? If this is what you are referring to
could you please provide a sample of how I would do that?

But if you are referring to the statements
EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3

Yes, I am. I am using FOR XML EXPLICIT

"Drebin" <tR************ *@hotmail.com> wrote in message
news:ur******** *********@newss vr33.news.prodi gy.com...
Inside those stored procedures - you are doing "for xml" on the select
statements??
"Mark Miller" <no**********@w aveshift.com> wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl...
I have an sp that outputs multiple xml fragments w/ no root. The sp calls individual sp's to output the correct set of data and each "type" has
different fields.

ex.:
<LEADERBOARD @Type='Rushing' >
<LEADER @Carries=''/>
</LEADERBOARD>
<LEADERBOARD @Type='QBRating '>
<LEADER @Rating='' @CompletionPct= ''/>
</LEADERBOARD>
<LEADERBOARD @Type='Tackles' >
<LEADER @Assisted='' @Tackles='' @Total=''/>
</LEADERBOARD>

I need to take the output and use XSLT to translate it to custom output.

But
no matter what I try I hit a dead end. Following is what I have tried.
1)
CREATE PROCEDURE GetAllLeaders_X ML
@Param1, @Param2, @Param3
AS

SET NOCOUNT ON

SELECT '<LEADERBOARDS> '
EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3
SELECT '</LEADERBOARDS>'

GO

with the following code (C#):
XmlReader rdrXml = cmdXML.ExecuteX mlReader();

or this:

DataSet dsXML = new DataSet();

dsXML.ReadXml(c mdXML.ExecuteXm lReader(), XmlReadMode.Fra gment);

result: "Invalid command sent to ExecuteXmlReade r(). The command must

return
an XML result.
2) If I remove the "root" LEADERBOARDS from before and after the sp's:

with the same code (C#)
(see #1 above)

result: "Object reference not set to an instance of an object. "

(btw. It doesn't matter if I use "ROOT" or "LEADERBOAR DS" as the root
element).

I have looked at SqlXmlCommand but I don't see how I can add multiple
parameters to pass to the sp. So if anyone can point me in the right
direction or provide me with some sample code to that effect I'd

appreciate
any help. Even if only to let me know if I could get a better answer from another ng. Everything I have tried works fine w/ other sp's that return a single, well-formed frament w/ a root element. I need help ASAP,
PLEEEEAASSSEEEE EE!


Nov 11 '05 #3
I appreciate your help. However, my problem actually lies with getting the
result set to the client. The root node is the least of my worries. I only
added it hoping the ExecuteXmlReade r method would then interpret the
resulting stream as a well formed XML document as opposed to a bunch of
fragments which is what I think it is doing.

I'm going to look into using a standard SqlDataReader or DataSet object to
get the data and then glue it all together before trying to pass it off as
all one XML docuement. But please if anyone has a better solution or can
point me in the right direction to using the SqlXmlCommand object I would
appreciate it.

Thanks,
mark
"Drebin" <tR************ *@hotmail.com> wrote in message
news:N2******** *********@newss vr32.news.prodi gy.com...
Yeah, you are right, you can only do individual tags, like this:

SELECT TOP 1
1 as Tag,
NULL as Parent,
GetDate() as [Leaderboard!1!]
FOR XML EXPLICIT

But not put the entire bit within that container - which is what I was
thinking.. My bad.

On another note, when I've done this in ASP, I always put the outside
container (like Leaderboard) on the client-side, then inserted the rest of
the XML inside that node.. but I should note, I have yet to get a .NET
version of this concept working, so I'm not much of an expert... :o)
"Mark Miller" <no**********@w aveshift.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
If you are referring to the statments:
SELECT '<LEADERBOARDS> '
and
SELECT '</LEADERBOARDS>'

no, I am not. I was not aware that was possible. Won't that wrap the text
"<LEADERBOARDS> " in another XML tag? If this is what you are referring to could you please provide a sample of how I would do that?

But if you are referring to the statements
EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3

Yes, I am. I am using FOR XML EXPLICIT

"Drebin" <tR************ *@hotmail.com> wrote in message
news:ur******** *********@newss vr33.news.prodi gy.com...
Inside those stored procedures - you are doing "for xml" on the select
statements??
"Mark Miller" <no**********@w aveshift.com> wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl...
> I have an sp that outputs multiple xml fragments w/ no root. The sp

calls
> individual sp's to output the correct set of data and each "type" has > different fields.
>
> ex.:
> <LEADERBOARD @Type='Rushing' >
> <LEADER @Carries=''/>
> </LEADERBOARD>
> <LEADERBOARD @Type='QBRating '>
> <LEADER @Rating='' @CompletionPct= ''/>
> </LEADERBOARD>
> <LEADERBOARD @Type='Tackles' >
> <LEADER @Assisted='' @Tackles='' @Total=''/>
> </LEADERBOARD>
>
> I need to take the output and use XSLT to translate it to custom

output. But
> no matter what I try I hit a dead end. Following is what I have tried. > 1)
> CREATE PROCEDURE GetAllLeaders_X ML
> @Param1, @Param2, @Param3
> AS
>
> SET NOCOUNT ON
>
> SELECT '<LEADERBOARDS> '
> EXEC Leaderboard_XML @LeaderType1, @param1, @param2, @param3
> EXEC Leaderboard_XML @LeaderType2, @param1, @param2, @param3
> EXEC Leaderboard_XML @LeaderType3, @param1, @param2, @param3
> SELECT '</LEADERBOARDS>'
>
> GO
>
> with the following code (C#):
> XmlReader rdrXml = cmdXML.ExecuteX mlReader();
>
> or this:
>
> DataSet dsXML = new DataSet();
>
> dsXML.ReadXml(c mdXML.ExecuteXm lReader(), XmlReadMode.Fra gment);
>
>
>
> result: "Invalid command sent to ExecuteXmlReade r(). The command must return
> an XML result.
>
>
> 2) If I remove the "root" LEADERBOARDS from before and after the sp's: >
> with the same code (C#)
> (see #1 above)
>
> result: "Object reference not set to an instance of an object. "
>
> (btw. It doesn't matter if I use "ROOT" or "LEADERBOAR DS" as the root > element).
>
> I have looked at SqlXmlCommand but I don't see how I can add multiple > parameters to pass to the sp. So if anyone can point me in the right
> direction or provide me with some sample code to that effect I'd
appreciate
> any help. Even if only to let me know if I could get a better answer

from
> another ng. Everything I have tried works fine w/ other sp's that

return
a
> single, well-formed frament w/ a root element. I need help ASAP,
> PLEEEEAASSSEEEE EE!
>
>



Nov 11 '05 #4

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

Similar topics

2
3624
by: Darko Jovisic | last post by:
Hi! Another silly question: If a stored procedure returns multiple result sets, how do I choose the one I want to insert into a table? For example sp_spaceused returns two result sets if object name is ommited. I only need the first result set. How do I do that?
4
10689
by: randy.p.ho | last post by:
Using JDBC, is there a way to call a stored procedure with multiple return values? Thanks.
3
2550
by: wxbuff | last post by:
I have a report based on our product names that consists of two parts. Both insert data into a temporary table. 1. A single grouped set of results based on all products 2. Multiple tables based on individual product names. I am getting data by calling the same stored procedure multiple times... for the single set of data I use "product like '%'" To get the data for individual products, I am using a cursor to parse
5
6800
by: adolf garlic | last post by:
Im trying to return xml from sql. The xml is made up of different fragments, some using FOR XML ... syntax. The result is a valid xml doc. There is a working stored proc that returns the xml In .net i'm having problems loading this up. I've now tried installing sqlxml managed classes and the following appears to work when stepping through, but the result just disappears.
0
1193
by: Steve Harclerode | last post by:
I'm trying to use an SqlCommand.ExecuteXmlReader() to write data to an XML file. Most of the code is below. The result I'm seeing is that the schema file is written and looks good, but the XML file has no data other than an empty <root> node. Is there something simple I'm missing? BTW, running the same query in query analyzer returns 7 nodes. Thanks -- Steve --------------------
5
8683
by: Stanley Sinclair | last post by:
I have a need to return multiple result sets from a stored procedure. Want that SP to call others to get the data. Win2003, db2 8.1.5. Can't figure out how to handle open cursors, and return >1 result sets. Thought about global temp tables.
1
3973
by: Soren Jorgensen | last post by:
Hi, When executing following statement "select distinct Name from CustomerParameters for xml auto" - XmlReader reads "<customerparameters name="Www.Mail.Generel" />" - but SQL Query Manager returns "<CustomerParameters Name="Www.Mail.Generel"/><CustomerParameters Name="Www.Mail.Updates"/>" I'm using following to read the result returned from the SqlConnection
4
15170
by: Steve Harclerode | last post by:
I tried this on another newsgroup but no nibbles -- I'm hoping someone might be able to help on this csharp group -- I'm trying to use SqlCommand.ExecuteXmlReader() to write data to an XML file. Most of the code is below. The result I'm seeing is that the schema file is written and looks good, but the XML file has no data other than an empty <root> node. Is there something simple I'm missing? BTW, running the same query in query analyzer...
15
6515
by: AussieRules | last post by:
Hi, I have a need to do two selects against to stored proc's in my SQL db. At the moment, each SP is called and two different dataset are populate. Thats two round trips to the SQL server. I can combine the two SP into one, and have one SP that executes two Select Statements, and effectivly returns two result sets, and I could call this with one trip to the SQL server from my VB app.
0
9666
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
9511
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
10200
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...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
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
7529
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...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.