Do a Find on a Dataset With Multiple Column Primary Key

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

How do I code a Find method for a dataset that has a multiple column primary
key. I tried the following but it won't accept the syntax of the Find. The
prinmary key is a combination of the name and uclass columns.

=========== code ===========
Public Function FindUnitRow(ByVal name As String, ByVal uclass As String)

FindUnitRow = ds.Tables(0).Rows.Find(name, uclass)

If FindUnitRow Is Nothing Then

MsgBox("Entry not found for: " & name & " - " & uclass,
MsgBoxStyle.Critical, "Unit Record Not Found")

End If

End Function

=======================================

Wayne
 
It turns out that you can use an array as the argument for the Find so this
looks like it will work: (won't be able to try it until I get the dataset
definition problem fixed)

============== code =================
Dim objFindValues(1) As Object

objFindValues(0) = name

objFindValues(1) = uclass



FindUnitRow = ds1.Tables(0).Rows.Find(objFindValues)

====================================
Wayne
 
Wayne,

Be aware that this is a find on a datatable rowscollection, there is not any
"find" of a Dataset.

There is as well a
datatable.select
datatable.defaultview.rowfilter
datatable.defaultview.find

I hope this helps,

Cor
 
Cor;

Thanks for the reminder. OOP and I don't always understand each other
(smirk!)

Wayne
 
Back
Top