Re: Treat a DataSet as a class structure

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I appreciate yours and everyone elses responses. Each has helped me get a
little further.

I'm now able to create and populate my XML and XSD files correctly. I can
even see the XSD "class structure" within my program now. However, I can't
figure out how to treat my dataset that is read in
(myDataSet.ReadXml(filename)) as a class structure.

I've tried SomeTests.TestGroupsDataTable table = new
SomeTests.TestGroupsDataTable((DataTable)myDataSet.Tables["Group"]) but this
only gives me a null table.

How do I reference the dataset as if it were a class structure?
--
-----------
Thanks,
Steve


"Luke Zhang [MSFT]" wrote:

Hello Steve,

To generate a XML file from XSD file created in DataSet designer, we need
create a dataset object, fill in data and use its WriteXml() method to
generate the XML data.

Also you can read XML data directly into a dataset, for example, test.xml:

<SomeTests>
<TestsGroups>
<Group TestName="TestA" >
<Test>Run1</Test>
<Test>Run2</Test>
<Test>Run3</Test>
</Group>
</TestsGroups>
</SomeTests>


(Your original XML is not valid for a dataset, so I modify a little)

DataSet ds = new DataSet();
ds.ReadXml("c:\\test.xml");

foreach (DataTable dt in ds.Tables)
{

System.Diagnostics.Debug.WriteLine(dt.TableName);
}

We will get three tables in the dataset; TestsGroup, Group and Test.
Anyway, this is not a strong typed dataset. To create a strong type
dataset, you need to create the schema in the dataset designer.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.




.



Relevant Pages

  • RE: XML Escaping for Textbox
    ... my understanding is that you use a TextBox on ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ... Subject: XML Escaping for Textbox ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How do I determine if a element exists in an xml file?
    ... As for the response XML document, does it have fixed schema or structure ... XML document is the reasonable approach. ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.languages.vb)
  • Re: To get row in XML
    ... What is the alternative way of getting rows in XML with ATL? ... Unfortunately I have not got a response from the development team. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.data.oledb)
  • Re: Parsing XML
    ... As for the XML Response stream, how did you get it, through HttpWebRequest ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.languages.vb)
  • Re: client-server protocol to object and back (study case)
    ... store the xml of the message and possible others members ... class with the boilerplate of the the response... ... parsing XML or even managing multiple fields positionally in a buffer is nontrivial. ... each subclass of [Encoder] would implement Encoder::encodeto go find the relevant attributes and encode them in the Message::data ADT. ...
    (comp.object)