[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sort dataset table

Posted on 2008-11-14
4
Medium Priority
?
954 Views
Last Modified: 2012-05-05
I have a dataset with one table the id is incremented, trying to sort a string field containing concatenated dateandtime - 20081113935.
Dim l_dv as dataview
l_dv = m_ds.Tables("Logs").defaultview
l_dv.sort = "DateAndSaveTime ASC"

This does not sort

Regads Neil
0
Comment
Question by:nenwmn
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 22959245
I would suggest creating a new DataView and sort that, then use the new DataView.  Sorting a DataTable within a DataSet just doesn't work, at least in my experience (if someone can prove me wrong, I'd be delighted to see how, would be a neat trick).
Dim l_dv as dataview
l_dv = New DataView(m_ds.Tables("Logs"))
l_dv.sort = "DateAndSaveTime ASC"

Open in new window

0
 

Accepted Solution

by:
Gesdev earned 1050 total points
ID: 22959290
It's probably because the column is not a true datetime - you mention you have it as a concatenated string?  I might be wrong, but sorting strings is completely different to sorting dates.  I'd recommend casting your datetime in your query and then try sorting again - there shouldn't be any need to recreate another dataview.
0
 
LVL 2

Author Comment

by:nenwmn
ID: 22959564
Gesdev the data comes from an xml log can I sort on the concatenated string.
0
 
LVL 23

Assisted Solution

by:Christopher Kile
Christopher Kile earned 450 total points
ID: 22959935
Gesdev,
I stand corrected :)
nenwmn,
Yes, you can sort on the concatenated string.  Any numeric, string, or datetime field should sort, though it sometimes is difficult to recognize that it is, in fact, sorted depending on the data involved.  Also, you need to make sure you are binding to the .DefaultView rather than to the table itself (once you've set the .Sort).
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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

872 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