Re: Treat a DataSet as a class structure
- From: SteveT <SteveT@xxxxxxxxxxxxxxxxx>
- Date: Wed, 4 Oct 2006 08:21:03 -0700
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.
- Follow-Ups:
- Re: Treat a DataSet as a class structure
- From: Luke Zhang [MSFT]
- Re: Treat a DataSet as a class structure
- References:
- Re: Treat a DataSet as a class structure
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Treat a DataSet as a class structure
- From: SteveT
- Re: Treat a DataSet as a class structure
- From: Luke Zhang [MSFT]
- Re: Treat a DataSet as a class structure
- Prev by Date: Re: .NET Framework v2.0
- Next by Date: Re: Command-line Program
- Previous by thread: Re: Treat a DataSet as a class structure
- Next by thread: Re: Treat a DataSet as a class structure
- Index(es):
Relevant Pages
|