Do a Find on a Dataset With Multiple Column Primary Key

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
 
W

Wayne Wengert

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
 
C

Cor Ligthert [MVP]

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
 
W

Wayne Wengert

Cor;

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

Wayne
 

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