vb.net web ap, sql server 2005, xml file

Posted on 2007-03-28
Medium Priority
Last Modified: 2013-11-26
I would like to create an xml file with vb.net web ap.  Can someone lead me in the right direction.  I need to read in fields from an sql server 2005 table to create this file.

Question by:Fraser_Admin
  • 5

Author Comment

ID: 18811070
or ideally it would be even better to have it generate from sql server stored procedure, so I can automatically email to the supplier.
LVL 30

Accepted Solution

nmcdermaid earned 2000 total points
ID: 18812446
If the table contains a field of type XML then you can just use BCP to export the XML field directly.

If you want to transform flat record(s) into XML then export it, you will probably need FOR XML to transform it, and BCP to export it.

This help reference (in SQL 20056 help) has a brief example of how to convert flat records into XML


You should be able to send the result of the SELECT to a text file.

Author Comment

ID: 18814987
this is my select statement and it is showing data_agent at the first.  is there a way for it to only say name??

SELECT agent_name as name, agent_number as number
FROM data_agent

<data_agent name="Agent1" number="BEB001" />
<data_agent name="Agent2" number="BOR001" />
<data_agent name="Agent3" number="BOW001" />

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.


Author Comment

ID: 18816149
I'm trying to use explicit and this is the error I'm getting:  How can you tell if a tag is open or closed?

Parent tag ID 1 is not among the open tags. FOR XML EXPLICIT requires parent tags to be opened first. Check the ordering of the result set.


Author Comment

ID: 18816569
ok i got that working, but i'm still not quite there.
i have
   <stuff 1=blah 2=blah/>

i nead
   <stuff 1>blah</stuff1>
   <stuff 2blah<stuff2/>

how do i get it to look like this??

Author Comment

ID: 18817387
ok i figured that out.  use element

Expert Comment

ID: 20239095
You don't need to create the file .Just write    FOR XML AUTO, ELEMENTS  after copletion of your select query.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question