By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,222 Members | 1,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,222 IT Pros & Developers. It's quick & easy.

Return datatable records that have a childrow that meets a search critieria

P: n/a
I have a datatable (I will call it 'main' datatable) with records that have
child rows. I need to select all the records from the main datatable where
the record/row has a childrow that meets a search criteria.

word to match="correctvalue"

row___
|---- childrow1(wrongvalue1)
|---- childrow2(wrongvalue2)
|---- childrow3(correctvalue) MATCH

If this occurs, I want to return the row.

My question is: Is there a neat way to do this, f.ex. using the select
method in the main datatable? Or am I basically stuck with iterating through
all the rows and childrows manually.

- Magnus
May 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
you can fill first table with this statement

select * from maintable

and fill child table with this statement

select childTable.* from childTable, mainTable
WHERE ((childTable.Id = mainTable.ID) AND (YOUR CONDITION HERE))

hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 23 '06 #2

P: n/a

"Galcho[MCSD.NET]" <ga****@gmail.com> skrev i melding
news:11**********************@j33g2000cwa.googlegr oups.com...
you can fill first table with this statement

select * from maintable

and fill child table with this statement

select childTable.* from childTable, mainTable
WHERE ((childTable.Id = mainTable.ID) AND (YOUR CONDITION HERE))

hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com


I should have mentioned, but the only data I have accessible is in a ado.net
datatable, I do not have the luxury of executing SQL queries against a sql
database.

The data in the ado.net datatable is loaded from a xml file.

- Magnus
May 23 '06 #3

P: n/a
then you can use DataTable.DefaultView.Filter property to enter your
condition for child table

hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com

May 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.