Question about searh possibilities in DataTable

T

tiger79

Hello,
I'd like to know what the search possibilities are within a DataTable ?
I know about the .Rows[index]["column name"] posiibility.
But is there any possibility of searching through the rows fo some known
value ?
Like having a table this way :
_____________________________________________
| name | Id# | Age |
| John | 1001 | 24 |
| Mark | 1002 | 37 |
| Pippo | 1010 | 29 |
| | | |

And now I'd like to select all records (rows) which have Id# equal to 1010
Is this possible ? And is it possible to place the results of this "query"
in a datareaderstrem ???
Thanks, I hope I explained my question in a proper way...
 
W

William Ryan eMVP

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
tiger79 said:
Hello,
I'd like to know what the search possibilities are within a DataTable ?
I know about the .Rows[index]["column name"] posiibility.
But is there any possibility of searching through the rows fo some known
value ?
Yes, you can use the DataTable's .Select method for one.
Like having a table this way :
_____________________________________________
| name | Id# | Age |
| John | 1001 | 24 |
| Mark | 1002 | 37 |
| Pippo | 1010 | 29 |
| | | |

And now I'd like to select all records (rows) which have Id# equal to 1010
Is this possible ?
You can also create a DataView on the datatable and use Find, FindRows
and/or set the Rowfilter ie dataView.RowFilter = "ID = '29' - The View's
..Count will match the instances of times where ID = 29, in this instance 1.

And is it possible to place the results of this "query"
in a datareaderstrem ???
No. DataReaders work when connected to a datasource. The datatable is
completely disconnected (hence their membership in different namespaces). I
know in the ADO.NET 2.0 Full framework you can create a datatable from a
reader but I don't know if that will be supported in the CF and somehow I
think it probably won't be - definitely not sure though. But for the time
being, most of those methods other than the Rowfilter property will simply
return an array of datarows - and those aren't available to be put in a
datareader without sticking them in the db and pulling them from there via
..ExecuteReader
 
T

tiger79

Yes, I have found a way to implement what I needed to ;)
thanx though for the help...

Graham McKechnie said:
Have you looked at DataTable.Select()

Graham
tiger79 said:
Hello,
I'd like to know what the search possibilities are within a DataTable ?
I know about the .Rows[index]["column name"] posiibility.
But is there any possibility of searching through the rows fo some known
value ?
Like having a table this way :
_____________________________________________
| name | Id# | Age |
| John | 1001 | 24 |
| Mark | 1002 | 37 |
| Pippo | 1010 | 29 |
| | | |

And now I'd like to select all records (rows) which have Id# equal to 1010
Is this possible ? And is it possible to place the results of this "query"
in a datareaderstrem ???
Thanks, I hope I explained my question in a proper way...
 

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

Top