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

Q: Searching the result of relationship

P: n/a
Hi

How can I search, using SQL commands, an arrow of rows generated from
GetChildRows. For example, suppose the result is given by:

Dim drMyRows() As DataRow = myTable(0).Rows.GetChildRows("MyChoices")

I would like to search for all the rows in drMyRows which satisfy an SQL
condition. I thought there may be a "Select" or "RowFilter" method I could
use but I can't find an example of one.

The only other thing I can think of is to iterate through each row and check
each one against the condition. Okay, it'll work, but I'd hoped there was an
inbuilt way to do it; if only in the hope it would be faster and more
efficient?

Can anybody help?

Thanks in advance

Geoff
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Geoff,

I showed you more times that when there is a childrelation, there should be
a filter item that makes the relation. You do not want to use that, why?

Am I missing something?

Cor
Nov 20 '05 #2

P: n/a
Geoff,
I'm not sure if this will work, but, it may help to get you in the right
direction. How are you getting an array of rows with out specifing which row
to get child rows from? Your code: Rows.GetChildRows("MyChoices"), Example
Code: Rows(0).GetChildRows("MyChoices").

Dim Rows() As DataRow = ds.Tables(0).Rows(0).GetChildRows("MyChoices")
Dim dt As New DataTable
For Each row As DataRow In Rows
dt.ImportRow(row)
Next
Rows = dt.Select("MyColumn=MyValue")

'OR

'Dim dv As New DataView(dt)
'Filter here

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi

How can I search, using SQL commands, an arrow of rows generated from
GetChildRows. For example, suppose the result is given by:

Dim drMyRows() As DataRow = myTable(0).Rows.GetChildRows("MyChoices")

I would like to search for all the rows in drMyRows which satisfy an SQL
condition. I thought there may be a "Select" or "RowFilter" method I could
use but I can't find an example of one.

The only other thing I can think of is to iterate through each row and
check
each one against the condition. Okay, it'll work, but I'd hoped there was
an
inbuilt way to do it; if only in the hope it would be faster and more
efficient?

Can anybody help?

Thanks in advance

Geoff

Nov 20 '05 #3

P: n/a
Hi Cor

No, your solution is very elegant and does indeed work. However, it does
surprise me that there are no other alternatives i.e. I would have expected
some kind of "Select" or "RowFilter" for an array of Rows. Obviously I'm
mistaken.

Geoff

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
Hi Geoff,

I showed you more times that when there is a childrelation, there should be a filter item that makes the relation. You do not want to use that, why?

Am I missing something?

Cor

Nov 20 '05 #4

P: n/a
Geoff,

When you write that, there is one, the find (the fastest) however that needs
a key in the rowscollection.

http://msdn.microsoft.com/library/de...sfindtopic.asp

Cor
Hi Cor

No, your solution is very elegant and does indeed work. However, it does
surprise me that there are no other alternatives i.e. I would have expected some kind of "Select" or "RowFilter" for an array of Rows. Obviously I'm
mistaken.

Geoff

Nov 20 '05 #5

P: n/a
Geoff,
How's that go? The third time is the charm.

I've answered this for you on both 7/6 & 7/13.

Instead of DataRow.GetChildRows use a DataView and use
DataRowView.CreateChildView.

Then you can set the RowFilter property of the DataView returned.

Dim view As New DataView(myTable)

For Each parent As DataRowView In view
Dim prices As DataView = parent.CreateChildView("PricesCompany")
prices.RowFilter = "Prices = '2'"
For Each price As DataRowView In prices
Debug.WriteLine(price!Prices, "Prices")
Debug.WriteLine(price!Company, "Company")
Next
Next

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40***********************@news.dial.pipex.com ...
Hi

How can I search, using SQL commands, an arrow of rows generated from
GetChildRows. For example, suppose the result is given by:

Dim drMyRows() As DataRow = myTable(0).Rows.GetChildRows("MyChoices")

I would like to search for all the rows in drMyRows which satisfy an SQL
condition. I thought there may be a "Select" or "RowFilter" method I could
use but I can't find an example of one.

The only other thing I can think of is to iterate through each row and check each one against the condition. Okay, it'll work, but I'd hoped there was an inbuilt way to do it; if only in the hope it would be faster and more
efficient?

Can anybody help?

Thanks in advance

Geoff

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.