473,320 Members | 2,048 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,320 software developers and data experts.

Problem with Dataset.WriteXML

This is the code:

Try
Dim con As New
SqlConnection("server=comwirsql;database=comwirdir ect;Trusted_Connection=yes")
Dim dGetData As SqlDataAdapter = New
SqlDataAdapter("sp_AccessUser2FTP", con)
dGetData.SelectCommand.CommandType =
Data.CommandType.StoredProcedure

Dim dDataset As New Data.DataSet
dGetData.Fill(dDataset)

With dDataset
.DataSetName = "AccessUser"
.WriteXml("E:\output.xml")
'.WriteXmlSchema("e:\output.xsd")
End With

dDataset.Dispose()
dGetData.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
End Try

This creates:

<AccessUser>
<Table>
<Lastname>hans</Lastname>
<Emailaddress1 />
</Table>
....

How do I avoid the creation of the Table tag?

Regards /Snedker
Aug 14 '07 #1
2 1633
Hi,

DataSet is memory representation of collection of tables. Thus you will
always have some tag representing table in dataset. You can use DataTable
instead of DataSet to reduce number of tags in resulting xml.

Regards,
Ladislav

"Morten Snedker" wrote:
This is the code:

Try
Dim con As New
SqlConnection("server=comwirsql;database=comwirdir ect;Trusted_Connection=yes")
Dim dGetData As SqlDataAdapter = New
SqlDataAdapter("sp_AccessUser2FTP", con)
dGetData.SelectCommand.CommandType =
Data.CommandType.StoredProcedure

Dim dDataset As New Data.DataSet
dGetData.Fill(dDataset)

With dDataset
.DataSetName = "AccessUser"
.WriteXml("E:\output.xml")
'.WriteXmlSchema("e:\output.xsd")
End With

dDataset.Dispose()
dGetData.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
End Try

This creates:

<AccessUser>
<Table>
<Lastname>hans</Lastname>
<Emailaddress1 />
</Table>
....

How do I avoid the creation of the Table tag?

Regards /Snedker
Aug 14 '07 #2
Thanks for input. Changed to datatable and all's well!

Regards /Snedker

Ladislav Mrnka skrev:
Hi,

DataSet is memory representation of collection of tables. Thus you will
always have some tag representing table in dataset. You can use DataTable
instead of DataSet to reduce number of tags in resulting xml.

Regards,
Ladislav

"Morten Snedker" wrote:
>This is the code:

Try
Dim con As New
SqlConnection("server=comwirsql;database=comwirdi rect;Trusted_Connection=yes")
Dim dGetData As SqlDataAdapter = New
SqlDataAdapter("sp_AccessUser2FTP", con)
dGetData.SelectCommand.CommandType =
Data.CommandType.StoredProcedure

Dim dDataset As New Data.DataSet
dGetData.Fill(dDataset)

With dDataset
.DataSetName = "AccessUser"
.WriteXml("E:\output.xml")
'.WriteXmlSchema("e:\output.xsd")
End With

dDataset.Dispose()
dGetData.Dispose()
Catch ex As Exception
Response.Write(ex.Message)
End Try

This creates:

<AccessUser>
<Table>
<Lastname>hans</Lastname>
<Emailaddress1 />
</Table>
....

How do I avoid the creation of the Table tag?

Regards /Snedker
Aug 14 '07 #3

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

Similar topics

4
by: Simon | last post by:
Hi all, I have a process, where I take a dataset from an SQL call, and need to write an XML file from that dataset. The data set can contain 10's of tables, each with 100's of rows, and I have...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
4
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset...
3
by: ad | last post by:
I test the XmlWrite/XmlRead from MemoryStrem, my codes is: DataSet ds = Will.DM.ExecuteDataset("Select * from Customer); MemoryStream msOri = new MemoryStream(); ds.WriteXml(msOri); DataSet...
3
by: jcrouse | last post by:
I have the following code that creates a couple of XML files: Dim dt1 As New DataTable("P1JoyUp") If H = True Then Dim dsH As New DataSet("HCPViewer") dsH.Tables.Add(dt1)
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: David Richards | last post by:
Hi, I was wondering if anyone could help me. I have DataSet that contains the following data tables Customers, Calls, Quotes, QuoteDetails, Competitors, Contacts, Notes, and I have setup...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
3
by: tasiekk | last post by:
I have typized DataSet. I can add to this dataset whatever i want but some specific date isnt writed to xml file after i make WriteXml. When i add row in code (not by hand in datagridview) it wont...
4
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a DataSet that I save as XML using the DataSet DataTable's WriteXml method. If I say XmlWriteMode.IgnoreSchema, it shows up great in Excel, but I can not reopen the file in my...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.