DataSet Cloning Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.WriteSchema);
///

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
 
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
 
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
 
Back
Top