finding records in ADO.net

  • Thread starter Thread starter Robert A. Boudra
  • Start date Start date
R

Robert A. Boudra

I'm looking for the equivalent of the Find method from ADO in ADO.net. It
appears that the Find method in .Net only works on the Key field. How do I
search for the first record in a DataSet that meets a given criteria?
 
Use The RowFilter Method of the DataView. DataView is a view of the
DataTable.

Regards - OHM
 
Robert,
You can use the a DataView.Filter as OHM suggests. Or you can use the
DataTable.Select method.

Note that the DataView.Filter property & DataTable.Select return a
collection of objects, not a position within the original DataTable.

David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press
covers this plus a plethora of other items about ADO.NET. I highly recommend
it as a good tutorial for ADO.NET & a good desk reference once you know
ADO.NET.

Hope this helps
Jay
 
Hi Robert,

As far as I remember me is the find in .Net almost the same as Seek in the
recordset.

But for a search you can do something like this
\\\
dim i as integer
for i = 0 to ds.tables(0).rowscount - 1
if ds.tables(0).rows(i)(myItem) = "mysearchcrit" then
exit for
end if
next
'i gives the index to your searched row
///
I hope this helps?

Cor
 
Back
Top