PC Review


Reply
Thread Tools Rate Thread

DataTable.rows.find

 
 
Calvin
Guest
Posts: n/a
 
      29th Jul 2003
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??


 
Reply With Quote
 
 
 
 
Prasad
Guest
Posts: n/a
 
      29th Jul 2003
Hi

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

HTH
Prasad

"Calvin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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??
>
>



 
Reply With Quote
 
Calvin
Guest
Posts: n/a
 
      29th Jul 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> The Array should be declared with length 3 and not 2.
>
> HTH
> Prasad
>
> "Calvin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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??
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable.Select vs DataTable.rows.Find vs foreach Dave Microsoft C# .NET 1 17th May 2007 09:06 PM
Updating datatable using datatable.rows.find() Lars E Microsoft C# .NET 1 27th Apr 2006 09:28 AM
Need WILDCARD search to find rows in a DataTable =?Utf-8?B?dmE=?= Microsoft ADO .NET 5 6th Jan 2006 06:53 PM
Find duplicate rows in datatable steve Microsoft ADO .NET 2 22nd Oct 2005 11:20 AM
DataTable.Rows.Find Sunny Microsoft C# .NET 1 4th Sep 2003 06:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:19 PM.