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

  • Thread starter Thread starter Magnus
  • Start date Start date
M

Magnus

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
 
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
 
Galcho said:
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
 
Back
Top