473,378 Members | 1,354 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,378 software developers and data experts.

Treat a DataSet as a class structure

Can someone point me in the right direction? Somewhere I read that you
reference a strongly typed dataset as if it were a class structure. For
example,

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

I want to reference this like SomeTest.TestGroups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve
Oct 3 '06 #1
7 2127
Steve,

Have you created this in the data set designer? You can add a new data
set to your project and then design it so that it mimics this structure.
Then, you should be able to access it in your code with strongly typed
accessors.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SteveT" <St****@newsgroups.nospamwrote in message
news:E3**********************************@microsof t.com...
Can someone point me in the right direction? Somewhere I read that you
reference a strongly typed dataset as if it were a class structure. For
example,

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

I want to reference this like SomeTest.TestGroups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve

Oct 3 '06 #2
=?Utf-8?B?U3RldmVU?= <St****@newsgroups.nospamwrote in
news:E3**********************************@microsof t.com:
Can someone point me in the right direction? Somewhere I read that
you reference a strongly typed dataset as if it were a class
structure. For example,

..NET has built in support for Typed Dataset.

http://www.15seconds.com/issue/031223.htm

However, also take a look at OR/M tools such as LLBLGen Pro and .NET teirs
- they're much more flexible (and MUCH more powerful).
Oct 3 '06 #3
Is there some example that walks one through how to do this done in the
designer with a XML / XSD file? I don't want to use a "database" and the
Designer seems to be written with that in mind. Once the DataSet is created,
will my dataset simple allow me to reference the contents as if it were the
DataSet?
--
-----------
Thanks,
Steve
"Nicholas Paldino [.NET/C# MVP]" wrote:
Steve,

Have you created this in the data set designer? You can add a new data
set to your project and then design it so that it mimics this structure.
Then, you should be able to access it in your code with strongly typed
accessors.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SteveT" <St****@newsgroups.nospamwrote in message
news:E3**********************************@microsof t.com...
Can someone point me in the right direction? Somewhere I read that you
reference a strongly typed dataset as if it were a class structure. For
example,

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

I want to reference this like SomeTest.TestGroups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve


Oct 3 '06 #4
Nicholas,

I've been reading up on this DataSet Designer. Do I need it or the XML
Designer to create the Schema that my code will understand? In the DataSet
Designer it looks like I have to use primary keys, but I don't want to. I
just want a nested relationship like the example I showed. Can the DataSet
Designer do this? Also, how to I create an XML file from the XSD file
created from the DataSet Designer. I know how to do it from the XML
Designer, but I've not used the DataSet Designer before.

--
-----------
Thanks,
Steve
"Nicholas Paldino [.NET/C# MVP]" wrote:
Steve,

Have you created this in the data set designer? You can add a new data
set to your project and then design it so that it mimics this structure.
Then, you should be able to access it in your code with strongly typed
accessors.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SteveT" <St****@newsgroups.nospamwrote in message
news:E3**********************************@microsof t.com...
Can someone point me in the right direction? Somewhere I read that you
reference a strongly typed dataset as if it were a class structure. For
example,

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

I want to reference this like SomeTest.TestGroups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve


Oct 3 '06 #5
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Oct 4 '06 #6
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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Oct 4 '06 #7
Normally, after we define Dataset and Datatable, we can create a new
datatable as:

DataSet1.DataTable1DataTable dt= new
DataSet1.DataTable1DataTable(SomeDataTable);

From your code

SomeTests.TestGroupsDataTable table = new
SomeTests.TestGroupsDataTable((DataTable)myDataSet .Tables["Group"])

Have you check the myDataSet.Tables["Group"] contians actual records, and
its schema exactly match with SomeTests.TestGroupsDataTable?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

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

Oct 5 '06 #8

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

Similar topics

0
by: José Joye | last post by:
I have used the wizard of VisualStudio to generate a DataSet (typed dataSet). I need to have the structure serialized in XML in a nested way and not in a table representation e.g: I have 3...
0
by: Greg Merideth | last post by:
I've got a web method returning 42 values that I need/would like to put into a class that has the same layout/structure. The dataset.merge works fine to retrieve the data from the web method but...
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
3
by: Mike N. | last post by:
Using VB.Net and ADO: I've created a public variable on my main form and set it to = a dataset which was crrated with the designer. I have another form with a datagrid on it. In the designer,...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
0
by: Islamegy® | last post by:
I was using WebService and i want to convert this WebService to Class Library so I Removed Inhertance and Attributes with no problems. But When i try to import Exist Dataset or TableAdapters i...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
5
by: Simon Woods | last post by:
Hi Does anyone know if there any dotnet software out there which converts a dataset into a collection of custom objects, programmatically i.e. actually creates the class structure and collection...
1
by: jc | last post by:
RE: Why use a CollectionBase class here vs dataset or dataview? I'm looking at some vb.net 2005 code that was generated from a homegrown Codesmith Template that generate all of the retreival and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.