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 3 1908
A datatable can belong to only one dataset.
Your can remove the datatable from the first dataset, add it to the second.
Do your processing, then remove it again and place it back in the original
dataset.
"jcrouse" <me> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl... 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
Hi John,
I think you are looking for dataset.clone or/and dataset.copy here.
Have a look on MSDN for that.
Cor
Resolved!
Thanks,
John
"jcrouse" <me> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl... 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: VK |
last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked"
question.
This question led to a long discussion about the naming rules applying to
variables, objects, methods and properties...
|
by: C# Learner |
last post by:
Why can't people abide by naming conventions?! It seems that most
people have to have their /own/ custom convention.
|
by: Mark Broadbent |
last post by:
stupid question time again to most of you experts but this is something that
continually bothers me.
I am trying to get into the habit of naming variables and controls in an
assembly as per...
|
by: 42 |
last post by:
Hi,
Stupid question:
I keep bumping into the desire to create classes and properties with the
same name and the current favored naming conventions aren't
automatically differentiating them......
|
by: Michelle Stone |
last post by:
Thanks for your message
I tried again and again... but didn't work. Can u please detail the
exact steps to perform?
This is what I do. In field explorer, i right-click the dataset to
update....
|
by: Jonathan Wood |
last post by:
I was just wondering what naming convention most of you use for class
variables.
Underscore, "m_" prefix, camel case, capitalized, etc?
Has one style emerged as the most popular?
Thanks for...
|
by: John |
last post by:
Hi,
I am developing a windows app using C# 2005. This app uses SQL Server or
Oracle database depending on the what the user is using.
Can I create one typed dataset and use it for SQL Server and...
|
by: Smithers |
last post by:
Is it common practise to begin the name of form classes with "frm" (e.g.,
frmOneForm, frmAnotherForm).
Or is that generally considered an outdated convention?
If not "frm" what is a common or...
|
by: Andy B |
last post by:
I need to custom build and use a dataset in c# to use with xml. Does anybody
know where I can find out how to do something like this? I was going to
create a class that generated the dataset and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |