DataRowCollection.Find

  • Thread starter Thread starter Scott Adams
  • Start date Start date
S

Scott Adams

When calling the Find function of a DataRowCollection, one has two options:

Overloads Public Function Find(ByVal key As Object) As DataRow
or
Overloads Public Function Find(ByVal keys() As Object) As DataRow

This function is easy to use if the primary key of your DataTable consists
of only one field. How can you use the Find functions if the primary key
consists of two database fields (composite key)?

Thanks in advance,

Scott Adams
 
Scott,

You want to use the second implementation of this method.

A code sample can be found in the MSDN library:
http://msdn.microsoft.com/library/d...ystemdatadatarowcollectionclassfindtopic2.asp

Basically you pass in an array of objects that contain values that you want
to find in the DataTable's primary key columns.

You may also have to set the Primary Key property of your DataTable from
which the DataRowCollection is coming.

A code sample for this can also be found in MSDN library:
http://msdn.microsoft.com/library/d...rfsystemdatadatatableclassprimarykeytopic.asp

Hope it helps.
 
Back
Top