finding records in ADO.net

  • Thread starter Robert A. Boudra
  • 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?
 
O

One Handed Man [ OHM# ]

Use The RowFilter Method of the DataView. DataView is a view of the
DataTable.

Regards - OHM
 
J

Jay B. Harlow [MVP - Outlook]

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
 
C

Cor

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
 

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