472,125 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

Serialize Dataset

I am attempting to generate an XML file based on the contents of a dataset
which contains a parent-child relationship but when I create the output file
all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to
datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below. Does
anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship ====================
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0).Columns("RegionalID"),
ds1.Tables(0).Columns("SeqNbr")}

PerfColumns = New DataColumn() {ds1.Tables(1).Columns("RegionalID"),
ds1.Tables(1).Columns("SeqNbr")}

Dim ShowSetsRel As New DataRelation("ShowSets", ShowColumns, PerfColumns)

'Add the Relation to the DataSet

ds1.Relations.Add(ShowSetsRel)
ShowSetsRel.Nested = True
============ XML Output code ================
Private Sub SerializeDataSet(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(GetType(DataSet))

Dim writer As TextWriter = New StreamWriter(filename)

ser.Serialize(writer, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub
Nov 12 '05 #1
2 9856
Use DataSet.WriteXml(stream, XmlWriteMode.WriteSchema);

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
I am attempting to generate an XML file based on the contents of a dataset
which contains a parent-child relationship but when I create the output file all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below. Does anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship ====================
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0).Columns("RegionalID"),
ds1.Tables(0).Columns("SeqNbr")}

PerfColumns = New DataColumn() {ds1.Tables(1).Columns("RegionalID"),
ds1.Tables(1).Columns("SeqNbr")}

Dim ShowSetsRel As New DataRelation("ShowSets", ShowColumns, PerfColumns)

'Add the Relation to the DataSet

ds1.Relations.Add(ShowSetsRel)
ShowSetsRel.Nested = True
============ XML Output code ================
Private Sub SerializeDataSet(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(GetType(DataSet))

Dim writer As TextWriter = New StreamWriter(filename)

ser.Serialize(writer, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub

Nov 12 '05 #2
Chris;

Thanks for the response but I am having a problem using that code. "stream"
is flagged as "Stream is a type and cannot be used as an expression" ?

Wayne

"Chris Lovett" <cl*****@microsoft.com.no_spam> wrote in message
news:ul*************@tk2msftngp13.phx.gbl...
Use DataSet.WriteXml(stream, XmlWriteMode.WriteSchema);

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
I am attempting to generate an XML file based on the contents of a dataset which contains a parent-child relationship but when I create the output file
all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to
datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below.

Does
anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship ====================
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0).Columns("RegionalID"),
ds1.Tables(0).Columns("SeqNbr")}

PerfColumns = New DataColumn() {ds1.Tables(1).Columns("RegionalID"),
ds1.Tables(1).Columns("SeqNbr")}

Dim ShowSetsRel As New DataRelation("ShowSets", ShowColumns,

PerfColumns)
'Add the Relation to the DataSet

ds1.Relations.Add(ShowSetsRel)
ShowSetsRel.Nested = True
============ XML Output code ================
Private Sub SerializeDataSet(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(GetType(DataSet))

Dim writer As TextWriter = New StreamWriter(filename)

ser.Serialize(writer, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by IMS.Rushikesh | last post: by
2 posts views Thread by Marty McDonald | last post: by
4 posts views Thread by Brian Keating | last post: by
4 posts views Thread by Abi | last post: by
6 posts views Thread by Paez | last post: by

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.