Sort dataset table

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
LVL 2
nenwmnAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Christopher KileCommented:
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
GesdevCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nenwmnAuthor Commented:
Gesdev the data comes from an xml log can I sort on the concatenated string.
0
Christopher KileCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.