Solved

loop through datatable in ascending order

Posted on 2014-04-06
3
477 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
Comment Utility
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 62

Expert Comment

by:Fernando Soto
Comment Utility
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
Comment Utility
For each r As DataRow In dt.Select("","SortColumnName DESC", _
                               DataViewRowState.CurrentRows
Next

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now