Help with datasets

G

Guest

Good morning all,

Heres what I have;
XML doc that had contacts setup inside it. Within each contact is a
lines group. Holds the phone lines for each contact.
I load up this xml into a dataset and what I end up with is;
Table 1 = My contacts, 2 of them for this test. Has all my columns
plus a new one the reader created, Contact_ID
Table 2 = A linkage table that the ReadXml cmd created when reading
in the data.
Has two fields: a] Contact_ID B] Phoneline_ID
Table 3 = Contacts PhoneLines, 3 rows for this test. Has all my
columns plus a new one the reader created, Phoneline_ID

Ok everything is fine here. Now what I want to do is somehow qurey this
dataset to return a dataview with a few fields from Table 1 and the
Line # field in Table 2.
How would I go about this? This is my first time playing with datasets. I
usually just use dataview objects that I populate thru SQL queries.

Thanks for the help
Deasun
 
G

Guest

Do you really need to return a DataView. You could use the DataTable.Select
method along with a filter that would give you back the appropriate rows.

If you wanted to get a bit more complicated, you could build up a new
dataset with a couple of tables by hand, add the appropriate columns to each,
add a relation between the two, get the rows from the originial dataset you
want via DataTable.Select(string filter) and populate the new dataset you've
created with the data.

While this might seem a little overblown, there currently isn't a way to
have a DataView sit on top of multile DataTables so this sort of becomes a
necessary evil.

Also, by having the relation in place, from the contact parent table you'll
be able to retrieve the children records from the second table via the
relations GetChildRows method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top