Private Sub FindInMultiPKey(ByVal myTable As DataTable)
Dim foundRow As DataRow
' Create an array for the key values to find.
Dim findTheseVals(2) As Object
' Set the values of the keys to find.
findTheseVals(0) = "John"
findTheseVals(1) = "Smith"
findTheseVals(2) = "5 Main St."
foundRow = myTable.Rows.Find(findTheseVals)
' Display column 1 of the found row.
If Not (foundRow Is Nothing) Then
Console.WriteLine(foundRow(1).ToString())
End If
End Sub

I find the example in msdn. I wonder why the array findTheseVals declared
dimension as 2 instead of 3. There are 3 key elements but the size of the
array is only 2??

Re: DataTable.rows.find by Prasad

Prasad
Mon Jul 28 23:40:16 CDT 2003

Hi

The Array should be declared with length 3 and not 2.

HTH
Prasad

"Calvin" <noemail@provided.com> wrote in message
news:O9CdGkXVDHA.424@TK2MSFTNGP11.phx.gbl...
> Private Sub FindInMultiPKey(ByVal myTable As DataTable)
> Dim foundRow As DataRow
> ' Create an array for the key values to find.
> Dim findTheseVals(2) As Object
> ' Set the values of the keys to find.
> findTheseVals(0) = "John"
> findTheseVals(1) = "Smith"
> findTheseVals(2) = "5 Main St."
> foundRow = myTable.Rows.Find(findTheseVals)
> ' Display column 1 of the found row.
> If Not (foundRow Is Nothing) Then
> Console.WriteLine(foundRow(1).ToString())
> End If
> End Sub
>
> I find the example in msdn. I wonder why the array findTheseVals declared
> dimension as 2 instead of 3. There are 3 key elements but the size of the
> array is only 2??
>
>



Re: DataTable.rows.find by Calvin

Calvin
Tue Jul 29 01:17:12 CDT 2003

yes. i think so. But if declared as 3, there is error saying expecting 3
values but receiving 4... error something like that

"Prasad" <prasadh_ms@hotmail.com> wrote in message
news:eAF1rtYVDHA.1928@TK2MSFTNGP12.phx.gbl...
> Hi
>
> The Array should be declared with length 3 and not 2.
>
> HTH
> Prasad
>
> "Calvin" <noemail@provided.com> wrote in message
> news:O9CdGkXVDHA.424@TK2MSFTNGP11.phx.gbl...
> > Private Sub FindInMultiPKey(ByVal myTable As DataTable)
> > Dim foundRow As DataRow
> > ' Create an array for the key values to find.
> > Dim findTheseVals(2) As Object
> > ' Set the values of the keys to find.
> > findTheseVals(0) = "John"
> > findTheseVals(1) = "Smith"
> > findTheseVals(2) = "5 Main St."
> > foundRow = myTable.Rows.Find(findTheseVals)
> > ' Display column 1 of the found row.
> > If Not (foundRow Is Nothing) Then
> > Console.WriteLine(foundRow(1).ToString())
> > End If
> > End Sub
> >
> > I find the example in msdn. I wonder why the array findTheseVals
declared
> > dimension as 2 instead of 3. There are 3 key elements but the size of
the
> > array is only 2??
> >
> >
>
>