473,401 Members | 2,125 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,401 software developers and data experts.

retrieve single values from typed DataSet - need help

Hi,

I used xsd.exe to generate a *.xsd file from the *.xml-File and then I
created a typed DataSet in VisualStudio 2003

But now I have problems to read the data from the DataSet.

<?xml version="1.0" encoding="UTF-8"?>
<Message id="100199" version="1.9" something="1">
<Jobs id="999" priority="0">
<DataContainer generationDate="19042005102504" RecordCount="1">
<CardRecord number="123456" number_id="00000099" crnSeq="1"
Perso="1000000000000123456">
<Module mic="modul_1">
<Data name="name" format="TEXT">Mustermann</Data>
</Module>
<Module mic="modul_2">
<Data name="boss" format="TEXT">Maier</Data>
</Module>
<Module mic="modul_3">
<Data name="chef" format="TEXT">Hauser</Data>
</Module>
</CardRecord>
</DataContainer>
</Jobs>
</Message>
I like to read the values from "Data". I am able to show all of these
data with the following code:
foreach (DataRow custRow in newDataSet1.Tables["Data"].Rows)
{
this.listBox1.Items.Add(custRow.ItemArray[2]);
}

But I need to read single data. I want only show the part of the
Data-table that belongs to "modul_1" or "modul_2".

Is my idea with "ItemArray" good? I believe that there is a better way
to retrieve the data but I was not able to find it.
Thanks for all tips.
Gruß
Thomas

Nov 17 '05 #1
2 2243
Thomas,

It would seem that you want to populate the list. Have you thought
about using DataBinding (through the DataSource and DisplayMember properties
on the ListBox)? This will prevent you from having to write looping code
like that.

Also, if you only want to show rows that meet a certain criteria, you
can use a DataView on the table with the rows, setting the Filter property
to the correct filter. Then, you can bind to the DataView.

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

"Thomas" <p_******@gmx.de> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,

I used xsd.exe to generate a *.xsd file from the *.xml-File and then I
created a typed DataSet in VisualStudio 2003

But now I have problems to read the data from the DataSet.

<?xml version="1.0" encoding="UTF-8"?>
<Message id="100199" version="1.9" something="1">
<Jobs id="999" priority="0">
<DataContainer generationDate="19042005102504" RecordCount="1">
<CardRecord number="123456" number_id="00000099" crnSeq="1"
Perso="1000000000000123456">
<Module mic="modul_1">
<Data name="name" format="TEXT">Mustermann</Data>
</Module>
<Module mic="modul_2">
<Data name="boss" format="TEXT">Maier</Data>
</Module>
<Module mic="modul_3">
<Data name="chef" format="TEXT">Hauser</Data>
</Module>
</CardRecord>
</DataContainer>
</Jobs>
</Message>
I like to read the values from "Data". I am able to show all of these
data with the following code:
foreach (DataRow custRow in newDataSet1.Tables["Data"].Rows)
{
this.listBox1.Items.Add(custRow.ItemArray[2]);
}

But I need to read single data. I want only show the part of the
Data-table that belongs to "modul_1" or "modul_2".

Is my idea with "ItemArray" good? I believe that there is a better way
to retrieve the data but I was not able to find it.
Thanks for all tips.
Gruß
Thomas
Nov 17 '05 #2
Hi Nicholas,

thanks for your answer.
Nicholas Paldino [.NET/C# MVP] schrieb:
Thomas,

It would seem that you want to populate the list. Have you thought
about using DataBinding (through the DataSource and DisplayMember properties
on the ListBox)? This will prevent you from having to write looping code
like that.
the ListBox is only for Debug. Later I will use the retrieved data in a
different way. So I do not need data bindings at the moment.
My inention for this little demo-programm is to write the three "items"
(Mustermann, Maier, Hauser) to three different strings.

Also, if you only want to show rows that meet a certain criteria, you
can use a DataView on the table with the rows, setting the Filter property
to the correct filter. Then, you can bind to the DataView.


I also tried to use a DataView but I was not able to set the filter
correct.
I think that I need some detailed help. I am trying different things
for hours now but I am not able to get a result :-(
Sincerely
Thomas

Nov 17 '05 #3

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

Similar topics

0
by: Anon | last post by:
I have an XML document that stores configuration settings for an app. I generated the schema using vs.net and also the corresponding dataset. I can load the config file (config.xml - below) and get...
4
by: jay | last post by:
I am using the dataset object to add a row to a sql server database in vb.net code, as follows: dim drow as DataRow dim cmdBld as new SqlCommandBuilder(mySqlDataAdapter) ds.tables(0).NewRow()...
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
1
by: tg.foobar | last post by:
my setup: visual studio 2005 sql server 2000 i'm using a dataset (used to be called typed dataset in 2003), where i use the MSDataSetGenerator to create a class for me based on the scheme of...
7
by: Peter | last post by:
Gday, I have a dataset with multiple tables, from which I want to access a single value in one of those tables. I know I can do something like: Decimal myVar =...
0
by: r1 | last post by:
I am relatively inexperienced in using delegates and asynchronous methods. I read several articles, and then I developed my own code with a mission to improve the performance. Wow! I cannot...
6
by: zoro | last post by:
Hi, I am looking for the recommended way to retrieve several values from a single record, i.e. a typical lookup scenario. An example would be a query that needs to retrieve user_name, user_addres,...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
3
by: Bjorn Sagbakken | last post by:
What is the best way to read single field values from a dataset? The dataset is populated with a customer record, showing well in a gridview. But I also want to read the single field values, like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.