J
jcrouse
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)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsH.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsH.Tables("P1JoyUp").Rows.Add(dr1)
dsH.WriteXml(SaveFileDialog1.FileName)
End If
If V = True Then
Dim dsV As New DataSet("VCPViewer")
dsV.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsV.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsV.Tables("P1JoyUp").Rows.Add(dr1)
dsV.WriteXml(SaveFileDialog1.FileName)
End If
If R = True Then
Dim dsrH As New DataSet("HCPViewer")
dsrH.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsrH.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsrH.Tables("P1JoyUp").Rows.Add(dr1)
dsrH.WriteXml(SaveFileDialog1.FileName)
Dim dsrV As New DataSet("VCPViewer")
dsrV.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsrV.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsrV.Tables("P1JoyUp").Rows.Add(dr1)
dsrV.WriteXml(SaveFileDialog1.FileName)
End If
If condition "H" is true I create a dataset HCPViewer and add a table dt1.
This works great.
If condition "V" is true i create a dataset VCPViewer and add a table dt1.
This also works great
If condition "R" is true I can run throught the "H" logic but when I get to
the "V" logic it errors out on the "dsrV.Tables.Add(dt1) line with the
following error:
An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: DataTable already belongs to another DataSet.
Is it true that I can't have the same table name in two different datasets
They are being written to completely different files. If I can't do this,
and it seems I can't, what are my options here?
Thank you,
John
Dim dt1 As New DataTable("P1JoyUp")
If H = True Then
Dim dsH As New DataSet("HCPViewer")
dsH.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsH.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsH.Tables("P1JoyUp").Rows.Add(dr1)
dsH.WriteXml(SaveFileDialog1.FileName)
End If
If V = True Then
Dim dsV As New DataSet("VCPViewer")
dsV.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsV.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsV.Tables("P1JoyUp").Rows.Add(dr1)
dsV.WriteXml(SaveFileDialog1.FileName)
End If
If R = True Then
Dim dsrH As New DataSet("HCPViewer")
dsrH.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsrH.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsrH.Tables("P1JoyUp").Rows.Add(dr1)
dsrH.WriteXml(SaveFileDialog1.FileName)
Dim dsrV As New DataSet("VCPViewer")
dsrV.Tables.Add(dt1)
dt1.Columns.Add("Top")
Dim dr1 As DataRow = dsrV.Tables("P1JoyUp").NewRow
dr1("Top") = lblP1JoyUp.Top.ToString
dsrV.Tables("P1JoyUp").Rows.Add(dr1)
dsrV.WriteXml(SaveFileDialog1.FileName)
End If
If condition "H" is true I create a dataset HCPViewer and add a table dt1.
This works great.
If condition "V" is true i create a dataset VCPViewer and add a table dt1.
This also works great
If condition "R" is true I can run throught the "H" logic but when I get to
the "V" logic it errors out on the "dsrV.Tables.Add(dt1) line with the
following error:
An unhandled exception of type 'System.ArgumentException' occurred in
system.data.dll
Additional information: DataTable already belongs to another DataSet.
Is it true that I can't have the same table name in two different datasets
They are being written to completely different files. If I can't do this,
and it seems I can't, what are my options here?
Thank you,
John