Solved

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

Posted on 2007-03-28
7
297 Views
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.

Thanks
0
Comment
Question by:Fraser_Admin
  • 5
7 Comments
 

Author Comment

by:Fraser_Admin
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.
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 500 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

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/ea58e90c-0a2a-4c8f-a7d6-d61618c2d11c.htm

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

Author Comment

by:Fraser_Admin
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
FOR XML AUTO

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

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Fraser_Admin
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.

0
 

Author Comment

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

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

how do i get it to look like this??
0
 

Author Comment

by:Fraser_Admin
ID: 18817387
ok i figured that out.  use element
0
 

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server memory Issue 7 76
Showdialog 8 21
SQL Split character from numbers 3 18
TSQL cursor within a batch takes long time.. 16 9
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now