Solved

loop through datatable in ascending order

Posted on 2014-04-06
3
482 Views
Last Modified: 2014-04-07
Hi experts
when I loop through datatable with the following code it starts at the top , but i would like to start at the bottom

for each row as datarow in dt.rows
next

thanks
0
Comment
Question by:b001
3 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39981527
try creating a recordset (based on a query) ordered DESC (or ASC) and, for each row in recordset

see http://support.microsoft.com/kb/168336
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39981564
Hi b001;

If you change your For Each loop as follows it will give you what you want.

For Each row As DataRow In dt.AsEnumerable().Reverse()
    ' ....
Next  

Open in new window

0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 39982052
For each r As DataRow In dt.Select("","SortColumnName DESC", _
                               DataViewRowState.CurrentRows
Next

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question