469,323 Members | 1,553 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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 9727
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.