473,396 Members | 1,608 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,396 software developers and data experts.

XML From Stored Proc

Jay
In VB.NET (Studio 2005) I need to loop thru a result set returned from a
stored proc and generate XML for each row. E.g. exex procWhatever returns:

custno, lname, fname, address
2, Doe, John, 123 4th St.
3, Smith, Bill, 567 8th St.
4, Grant, Terry, 333 Wherever St.

For each on of those rows I need to generate (string):

<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>

....
Any advice, tutorials, etc. would be greatly appreciated. Thank you very
much.

May 17 '06 #1
4 1401
What database? If SQL Server, you have the option of outputting as XML,
using FOR XML.

If not, you will have to do it yourself. One of the easiest means is taking
the DataSet XML (GetXml()) and transforming it with XSLT to the format you
would like.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Jay" <msnews.microsoft.com> wrote in message
news:u6**************@TK2MSFTNGP03.phx.gbl...
In VB.NET (Studio 2005) I need to loop thru a result set returned from a
stored proc and generate XML for each row. E.g. exex procWhatever
returns:

custno, lname, fname, address
2, Doe, John, 123 4th St.
3, Smith, Bill, 567 8th St.
4, Grant, Terry, 333 Wherever St.

For each on of those rows I need to generate (string):

<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>

...
Any advice, tutorials, etc. would be greatly appreciated. Thank you very
much.

May 17 '06 #2
Jay
Thanks for the prompt response. The database is SQL 2005 but when I return
the results using FOR XML AUTO, ELEMENTS I receive all customers in one xml
document like so:
<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>
<Customer>
<custno>3</custno>
<lname>Smith</lname>
<fname>Terry</fname>
<address>456 7th st..</address>
</customer>
....
....

I can return this to VB.NET but I need to loop thru and use each row
individually, not as an entire document.

So I figure if I remove for xml auto, elements from the query/proc I can
genetate the xml for each row individually within vb.net... unless here is
an easier way to do it with the xml results returned from sql server.

Any thoughts, recommendations? Thanks a lot.

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:u3**************@TK2MSFTNGP02.phx.gbl...
What database? If SQL Server, you have the option of outputting as XML,
using FOR XML.

If not, you will have to do it yourself. One of the easiest means is
taking the DataSet XML (GetXml()) and transforming it with XSLT to the
format you would like.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Jay" <msnews.microsoft.com> wrote in message
news:u6**************@TK2MSFTNGP03.phx.gbl...
In VB.NET (Studio 2005) I need to loop thru a result set returned from a
stored proc and generate XML for each row. E.g. exex procWhatever
returns:

custno, lname, fname, address
2, Doe, John, 123 4th St.
3, Smith, Bill, 567 8th St.
4, Grant, Terry, 333 Wherever St.

For each on of those rows I need to generate (string):

<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>

...
Any advice, tutorials, etc. would be greatly appreciated. Thank you very
much.


May 17 '06 #3
Jay,

XML is only a way of how to describe data. Which can be used in many ways.

If you use it inside ADONET than you mostly using a datatable (which can be
wrapped inside a dataset)

For that you need only a simple Select command describing what you want and
than
A SQLConnection
A DataTable
A SQLDataAdapter
the SQL Select command

If you use than the dataadapter as
da.Fill(myTable) than you have it.

Inside and around the DataSet/DataTable are and endless amount of methods by
instance the DataSet/DataTable writeXML and ReadXml.

I hope this helps,

Cor
"Jay" <msnews.microsoft.com> schreef in bericht
news:u6**************@TK2MSFTNGP03.phx.gbl...
In VB.NET (Studio 2005) I need to loop thru a result set returned from a
stored proc and generate XML for each row. E.g. exex procWhatever
returns:

custno, lname, fname, address
2, Doe, John, 123 4th St.
3, Smith, Bill, 567 8th St.
4, Grant, Terry, 333 Wherever St.

For each on of those rows I need to generate (string):

<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>

...
Any advice, tutorials, etc. would be greatly appreciated. Thank you very
much.

May 17 '06 #4
Using FOR XML EXPLICIT, you can create most any XML structure you want.
"Jay" <msnews.microsoft.com> wrote in message
news:e5**************@TK2MSFTNGP03.phx.gbl...
Thanks for the prompt response. The database is SQL 2005 but when I
return the results using FOR XML AUTO, ELEMENTS I receive all customers in
one xml document like so:
<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>
<Customer>
<custno>3</custno>
<lname>Smith</lname>
<fname>Terry</fname>
<address>456 7th st..</address>
</customer>
...
...

I can return this to VB.NET but I need to loop thru and use each row
individually, not as an entire document.

So I figure if I remove for xml auto, elements from the query/proc I can
genetate the xml for each row individually within vb.net... unless here is
an easier way to do it with the xml results returned from sql server.

Any thoughts, recommendations? Thanks a lot.

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:u3**************@TK2MSFTNGP02.phx.gbl...
What database? If SQL Server, you have the option of outputting as XML,
using FOR XML.

If not, you will have to do it yourself. One of the easiest means is
taking the DataSet XML (GetXml()) and transforming it with XSLT to the
format you would like.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Jay" <msnews.microsoft.com> wrote in message
news:u6**************@TK2MSFTNGP03.phx.gbl...
In VB.NET (Studio 2005) I need to loop thru a result set returned from a
stored proc and generate XML for each row. E.g. exex procWhatever
returns:

custno, lname, fname, address
2, Doe, John, 123 4th St.
3, Smith, Bill, 567 8th St.
4, Grant, Terry, 333 Wherever St.

For each on of those rows I need to generate (string):

<Customer>
<custno>2</custno>
<lname>Doe</lname>
<fname>John</fname>
<address>123 4th st.</address>
</customer>

...
Any advice, tutorials, etc. would be greatly appreciated. Thank you
very much.



May 17 '06 #5

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

Similar topics

2
by: June Moore | last post by:
Hi all, I have a stored procedure that return a resultset e.g. stored proc: get_employee_details select emp_id, emp_name, emp_salary, emp_position from empoloyee I would like to write...
9
by: Wolfgang Kreuzer | last post by:
Try hard to become familiar with T-SQL. Can anybodey tell me the best way to deal with set's provided by a stored procedure. Til yesterday I thougt trapping set in temp table using INSERT EXEC...
4
by: Nyul | last post by:
Gurus, I have a verb big problem which I'm unable to explain. We have a DB2 V6.1.0 on AIX 4.3 I want to make a C stored procedure which at the end will be called by a PHP script. The...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
5
by: Rhino | last post by:
This question relates to DB2 Version 6 on OS/390. Can a (COBOL) stored procedure on this platform do file I/O, i.e. write to a sequential file? I am trying to debug a stored procedure. As far...
2
by: Rhino | last post by:
I am getting an sqlcode of -927 when I execute SQL within a COBOL stored procedure in DB2 OS/390 Version 6 on OS/390. I have looked at the error message for that condition and tried everything I...
1
by: mike | last post by:
If I try and do a "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1" after I have run a stored procedure in DB2 version 7.2, I get the last generated Key before the CallableStatement was executed...
14
by: Roy | last post by:
Apologies for the cross-post, but this truly is a two-sided question. Given the option of creating Looping statements within a stored proc of sql server or in the code-behind of an .net webpage,...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
0
by: mirandacascade | last post by:
Questions toward the bottom of the post. Situation is this: 1) Access 97 2) SQL Server 2000 3) The Access app: a) sets up pass-thru query b) .SQL property of querydef is a string, the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.