473,811 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.TestGr oups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve
Oct 3 '06 #1
7 2156
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.co m

"SteveT" <St****@newsgro ups.nospamwrote in message
news:E3******** *************** ***********@mic rosoft.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.TestGr oups.Group.Test[a]. Is this
possible?
--
-----------
Thanks,
Steve

Oct 3 '06 #2
=?Utf-8?B?U3RldmVU?= <St****@newsgro ups.nospamwrote in
news:E3******** *************** ***********@mic rosoft.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.co m

"SteveT" <St****@newsgro ups.nospamwrote in message
news:E3******** *************** ***********@mic rosoft.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.TestGr oups.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.co m

"SteveT" <St****@newsgro ups.nospamwrote in message
news:E3******** *************** ***********@mic rosoft.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.TestGr oups.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.Diagnost ics.Debug.Write Line(dt.TableNa me);
}

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.Read Xml(filename)) as a class structure.

I've tried SomeTests.TestG roupsDataTable table = new
SomeTests.TestG roupsDataTable( (DataTable)myDa taSet.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.Diagnost ics.Debug.Write Line(dt.TableNa me);
}

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.DataTa ble1DataTable dt= new
DataSet1.DataTa ble1DataTable(S omeDataTable);

From your code

SomeTests.TestG roupsDataTable table = new
SomeTests.TestG roupsDataTable( (DataTable)myDa taSet.Tables["Group"])

Have you check the myDataSet.Table s["Group"] contians actual records, and
its schema exactly match with SomeTests.TestG roupsDataTable?

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
1195
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 tables: Companies- Departments- Employees A company can have n Departments and a Department can have m employees By default the DataSet is serialized this way:
0
1092
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 I'm at a loss as to how to get the data in the dataset into a class via serialization. The dataset, when I serialize has the schema information along with the elements(rows) of data however when I attempt to get that back into a class using...
7
6237
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 in the same format as the XSD (the XML file/string was created using this same schema). The XML file/string may contain data for a single table or for several tables at once. The question is:
3
3358
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, I can't set the datasource property to the dataset on the main form, although i can do it in code. Can someone tell me how to declare a dataset, either in a form or module, that I can use globally throughout my application, including in the...
22
25610
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 compile. <WebMethod()> _ Public Function VerifySku(ByVal skus As XmlDataDocument) As DataSet Test program : Dim cartSet As DataSet cartSet = ws.VerifySku(cartSet)
0
1342
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 get errors in connectionstring and sometimes it give object refrence exception.. I discovered that the Dataset structure is not the same, in webservice everything is Xml and no class code but in class library dataset it's deffrent. Is there...
15
13518
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 http://msdn2.microsoft.com/en-us/library/ms996381.aspx Formerly, with classic Microsoft DNA architecture, the ADO Recordset was a primary transport medium, recommended for transmitting data between application tiers. In fact, there are whole books written on the subject.
5
3492
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 class on-the-fly based on the fields in the dataset and then creates and populates the classes and adds them into the collection. Thanks
1
2588
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 update code for typical vb.net / asp.net data maintenance applications. For some reason they have two class files for each table, one is a collection class. Oddly both have the same properties for each table column duplicated.. a lot of duplicate...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10663
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7676
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.