Help with searching DataRow array...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I'm having some difficulty searching a set of rows in a DataRow collection..
This is my question
What would be an efficient way to search any column of an DataRow array

Let me try to explain the context of this question, that will help you understand what I'm looking for..
Assume that I have a collection of rows that came out of a statement like this
dim myRows() as DataRow = myTable.Select("any query"

Now that I have this array of rows, I need to find an specific row that matches certain criteria..
For example, "name = Joe"..
If I look at the available options from intellisense when I type "myRows.", I cannot find any function or method that I can call and pass my further search query for a field "name" that contains "Joe"..

With this scenario in mind, my real problem does not allow me to pass to the "myTable" DataTable one select command already containing "name = 'Joe'" because I don't have access to the DataTable
This portion of the code receives rows, and can only deal with them, not with the original datatable

Back to the question
What would be an efficient way to search any column of an DataRow array

Thanks in advance for any help you can provide

Carlos
 
Hi Carlos,

Because you have not any access to the datatable you have not any tool also.
The datarowcollection.find is excelent for your question, but for that it
has to be the primarykey in the datatable.

When you have a lot of search to do you can of course build a datatable
back.
When it are a few you should use the normal for index loop (and exit that if
you found your row)

I hope this helps,

Cor
I'm having some difficulty searching a set of rows in a DataRow collection...
This is my question:
What would be an efficient way to search any column of an DataRow array?

Let me try to explain the context of this question, that will help you
understand what I'm looking for...
Assume that I have a collection of rows that came out of a statement like this:
dim myRows() as DataRow = myTable.Select("any query")

Now that I have this array of rows, I need to find an specific row that matches certain criteria...
For example, "name = Joe"...
If I look at the available options from intellisense when I type
"myRows.", I cannot find any function or method that I can call and pass my
further search query for a field "name" that contains "Joe"...
With this scenario in mind, my real problem does not allow me to pass to
the "myTable" DataTable one select command already containing "name = 'Joe'"
because I don't have access to the DataTable!
 
Thanks for the ideas, Cor...

I'm thinking about re-building the datatable locally and
then search.

That might be faster for my application.

Thanks again,
Carlos
 
Back
Top