473,779 Members | 2,050 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 7736
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
3623
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
1190
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
3972
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
15168
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
9633
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
10305
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10137
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
10074
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
9928
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7483
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
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
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.