Solved

loop through datatable in ascending order

Posted on 2014-04-06
3
487 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending receiving text messages in vb.net 15 63
Generate Numbers in JQuery file 11 72
SSRS 2016 Rendering HTML tables 3 63
Need help with another query 10 40
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 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