Find 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 DataTable that meets a given criteria?
 
W

William Ryan

One way is to create a DataView and set its rowfilter to the value that you
are looking for
 
B

Bernie Yaeger

Hi Robert,

There's a find method in a dataview that does not rely on the PK. Here's a
skeleton:
Dim arrayseeks(0) As Object

Dim ifinds As Integer

Dim vues As New DataView(dsshipcode.Tables(0))

vues.Sort = "shipcode"

For Each irowd In dsmani_lbld.Tables(0).Rows

qcounter = 0

For Each irow In dsmani_lbl.Tables(0).Rows

arrayseeks(0) = irow("shipcode")

ifinds = vues.Find(arrayseeks)

If ifinds <> -1 Then ' ie, found it

mdescrip = vues(ifinds)("descrip")

Else

mdescrip = ""

End If

Next

Let me know if you have any questions.

HTH,

Bernie Yaeger
 

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