|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataView.Findmethod. The latter searches the Primary Key of the table for the object supplied as the "key" parameter. However, where the DataView.Find is concerned, it seems that the Primary Key of the table is not the column searched, rather, it is the column specified in the DataView.Sort member. So far so good. But, what happens with the DataView.Find(key()) flavor of this method. I assume that it will again search the DataView.Sort member column, but what happens when the Key is an array with more than one element? If I use dim key(1) as Object, and then assign each element a value, does that mean that the DataView.Sort member must be made up of 2 columns, seperated by a comma? Michael PS. I also noticed that the method return's -1 and not null when a row isn't found. -- Michael Hockstein Hi Michael,
First of all, I would like to confirm my understanding of your issue. From your description, I understand that there is some misleading in the MSDN documentation for DataView.Find method. If there is any misunderstanding, please feel free to let me know. Actually, DataView.Find accept values for the columns on which DataView is actually sorted which is not always primary key columns. The overload for DataView.Find(object[]) is used when multiple columns are used as sort columns. The example in the MSDN document won't work. Here, I'm posting a correct example: DataView dv = new DataView(dt); dv.Sort = "FirstName, LastName"; this.dataGrid1.DataSource = dv; object[] s = {"Nancy", "Davolio"}; int i = dv.Find(s); We have noticed this issue, and you can check it from the following link: http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=4 c26fdcd-1e3d-48a9-96b3-ef0b066b5861 This will be fixed soon. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." Maybe the documentation will be better in 2005.
Which method do you think would be faster, all other things equal(# of rows, # of columns in key), the method in the DataRowCollection or the Dataview? Michael Show quote "Kevin Yu [MSFT]" wrote: > Hi Michael, > > First of all, I would like to confirm my understanding of your issue. From > your description, I understand that there is some misleading in the MSDN > documentation for DataView.Find method. If there is any misunderstanding, > please feel free to let me know. > > Actually, DataView.Find accept values for the columns on which DataView is > actually sorted which is not always primary key columns. The overload for > DataView.Find(object[]) is used when multiple columns are used as sort > columns. The example in the MSDN document won't work. Here, I'm posting a > correct example: > > DataView dv = new DataView(dt); > dv.Sort = "FirstName, LastName"; > this.dataGrid1.DataSource = dv; > object[] s = {"Nancy", "Davolio"}; > int i = dv.Find(s); > > We have noticed this issue, and you can check it from the following link: > > http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=4 > c26fdcd-1e3d-48a9-96b3-ef0b066b5861 > > This will be fixed soon. HTH. > > Kevin Yu > ======= > "This posting is provided "AS IS" with no warranties, and confers no > rights." > > Hi Michael,
The two methods, DataRowCollection.Find and DataView.Find, find data in different kind of columns. DataRowCollection.find must find in a column that is the primary key in a DataTable, while DataView.Find must find in a sorted column. If the primary key column is also the sorted column, I think DataView.Find will be faster, since it looks for rows in a sorted column. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights." |
|||||||||||||||||||||||