?
Solved

loop through datatable in ascending order

Posted on 2014-04-06
3
Medium Priority
?
491 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 28

Accepted Solution

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

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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