>1) It helps if you indicate why it isn't working. What sort of error are you getting.
There is no error. The sort is just not taken into consideration.
>2) Why don't you want to use a For Each? Unless you are adding or removing from the collection, or need the index for some reason, it will prevent IndexOutOfRange errors and populate your loRow variable automatically.
Because I need to have a For/Next approach so I can benefit of a counter instead of doing it myself. Also, I have sub loops which are depending on such counter.
>3) Your first example doesn't show where oRows is being populated. Your second example shows it coming from the table. If you are going off the table, it is probably in the same order it was retrieved from the database. You should be looping through your DataView. If your first example was in order and also going off of the datatable, it is probably a coincidence.
This is used in various applications at various locations. But, wherever it applies, it is always related to the fact that I am creating a dataset manually. In those, the default order is not always are wanted and when I use the Sort, it reorders the order of the rows that will be processed in the For/Next. So, I doubt it is a coincidence and I cannot be. The first example is initializing oRows from:
oRows = oDataSet.Tables("Temp").Rows()
>4) If you need to access the DataRow, instead of using the DataRowView, you can do so through the DataRowView.Row property (
http://msdn.microsoft.com/en-us/library/system.data.datarowview.row.aspx).
Thanks
>5) You may have better performance using LINQ instead of the DataView:
http://www.adathedev.co.uk/2010/02/sorting-datatable-linq-performance.html.
Thanks