Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sorting a dataset
Message
From
17/07/2013 19:01:43
 
 
To
17/07/2013 18:05:50
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01578641
Message ID:
01578670
Views:
45
>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:
            ' Make oRows available
            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
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform