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

DataSet Cloning Problem

I have some xml that I am loading into a DataSet. Later in my program I have
to clone that DataSet but I keep getting an error saying that I can't have a
table named the same as my DataSet?!?

If I look at the original DataSet it's is named "MEDIA" and there is a table
in it called "media". If you can't have a table named the same as the DataSet
then why is this happening in the original xml DataSet?

I really need to clone this DataSet so that I get all the Table and
Relationship structures.

Please help!

David

=====================
David McCarter
www.vsdntips.com
Jul 21 '05 #1
3 1252
David,

I tried this code.
\\\
DataSet ds = new DataSet("Media");
DataTable dt = new DataTable("Media");
dt.Columns.Add("Media");
dt.Rows.Add(dt.NewRow());
dt.Rows[0][0] = "Media";
ds.Tables.Add(dt);
ds.WriteXml("C:\\Test1\\Media.XML",XmlWriteMode.Wr iteSchema);
///

It gave this dataset,

<?xml version="1.0" standalone="yes"?>
<Media>
<xs:schema id="Media" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Media" msdata:IsDataSet="true" msdata:Locale="nl-NL">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Media">
<xs:complexType>
<xs:sequence>
<xs:element name="Media" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Media>
<Media>Media</Media>
</Media>
</Media>

Therefore can you explain it a little bit more?

Cor
Jul 21 '05 #2
Yes, you are right, that works, but for some reason cloning won't work for
the DataSet that I create with the xml below using DataSet.ReadXml:

<Media xmlns="http://mycompany.com/MediaConfig">
<Type>Encode</Type>
<Standard>NTSC</Standard>
<Peripheral>
<ID>1</ID>
<NumWindows>1</NumWindows>
<Video>
<Name>Camera #1</Name>
<Source>0</Source>
<FrameRate>30</FrameRate>
<BitRate>3000000</BitRate>
<Resolution>4CIF</Resolution>
<McastIP>239.128.0.153</McastIP>
<Port>4000</Port>
</Video>
<Audio>
<Source>LEFT</Source>
<SampleRate>16000</SampleRate>
<McastIP>235.0.0.52</McastIP>
<Port>4001</Port>
</Audio>
</Peripheral>
</Media>

If you have any suggestions, please let me know.

David

"Cor Ligthert" wrote:
David,

I tried this code.
\\\
DataSet ds = new DataSet("Media");
DataTable dt = new DataTable("Media");
dt.Columns.Add("Media");
dt.Rows.Add(dt.NewRow());
dt.Rows[0][0] = "Media";
ds.Tables.Add(dt);
ds.WriteXml("C:\\Test1\\Media.XML",XmlWriteMode.Wr iteSchema);
///

It gave this dataset,

<?xml version="1.0" standalone="yes"?>
<Media>
<xs:schema id="Media" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Media" msdata:IsDataSet="true" msdata:Locale="nl-NL">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Media">
<xs:complexType>
<xs:sequence>
<xs:element name="Media" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Media>
<Media>Media</Media>
</Media>
</Media>

Therefore can you explain it a little bit more?

Cor

Jul 21 '05 #3
Dave

I did this with your dataset and no problem at all
\\\
Dim ds As New DataSet
ds.ReadXml("xmlfile1.xml") 'your dataset
Dim ds2 As New DataSet
ds2 = ds2.Clone
Dim dt As New DataTable("media")
ds2.Tables.Add(dt)
///

Maybe it is easier when you show some code?

Cor
Jul 21 '05 #4

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

Similar topics

11
by: Nikki | last post by:
Is it possible to sort a dataset rather than a dataview? I have a web service that returns a dataset which I would like to sort before returning it (this is so the sorting is standardised and so...
3
by: Bill | last post by:
I have a seating chart web form that has over 50 entry field controls (tables/booths) where I use a DropDownList box to select a single company name from a single large list of organizations (200...
3
by: Dmitry Karneev | last post by:
Hi! I have a rather interesting problem. I have a dataset that contatin data from database. I need to clone this dataset with data but all id's in tables must be NULL and all DataRowStates must...
8
by: Tom | last post by:
I've a problem. I want to clone an object having a list of other objects (and so on :/). Do you know any other way than ICloneable.Clone() implementation for all classes in the way? Help..
3
by: dotNetDave | last post by:
I have some xml that I am loading into a DataSet. Later in my program I have to clone that DataSet but I keep getting an error saying that I can't have a table named the same as my DataSet?!? If...
11
by: MurdockSE | last post by:
Greetings. My Situation: // I have an .xml file that I am reading into a dataset in the following code - DataSet ds = new DataSet("MyDataset"); ds.ReadXml(@"c:\data\"+cmyxmlfilename);
3
by: raylopez99 | last post by:
The "C# Cookbook" (O'Reilly / Jay Hilyard), section 3.26, is on deep cloning versus shallow cloning. The scanned pages of this book are found here: http://www.sendspace.com/file/mjyocg (Word...
1
by: Dan Dorey | last post by:
I've implemented the ICloneable interface on one of my class. I've written this simple code in two different ways and I think both should work but it's not the case and I'm curious to understand...
0
by: Chris | last post by:
Hi All. I'm cloning a treenode, like so: TreeNode trNewTemp = new TreeNode(); trNewTemp = ((((ICloneable)trTempNode).Clone()) as TreeNode); Now the cloning works- trNewTemp has the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.