Select columns in DataSet

  • Thread starter Thread starter Diego F.
  • Start date Start date
D

Diego F.

Hello.

I load a DataSet with a XML file and I need to select data from certain
columns. How can I do that?

To explain it better, suppose you have this XML

<users>
<user>
<name> Diego </name>
<country> Spain </country>
</user>
<user>
<name> John </name>
<country> UK </name>
</user>
</users>

What I want to get is a table with all users from a certain country.
Now I'm loading all the XML in a DataSet with the ReadXML method, but I
don't know how to select columns inside the DataSet.

Regards,

Diego F.
 
Thanks for your answer. With this I get only one cell. I need all the cells
that matches a city.
If I were working with a database it would be: "select * from users where
country=spain.

Is it possible with DataSet?

Regards,

Diego F.
 
Hi Diego,

In VB.net style

Dim dr() as datarow = ds.tables(0).select("country=spain")

However I prefer the dataview because that is faster
dim dv as new dataview(ds.tables(0))
dv.sort = "country"
dv.rowfilter = "country=spain"

I hope this helps?

Cor
 
You want actually to select lines from your dataset. Use
DataTable.DefaultView.RowFilter and enter your criteria to get filtered data
(all the Data are still available in DataTable.Rows, you'll find only the
filtered records in DataTable.DefaultView.Item).

Patrice
 
Back
Top