?
Solved

Help with sorting column is DataTable using vb.net

Posted on 2014-02-23
6
Medium Priority
?
2,659 Views
Last Modified: 2014-02-24
Hi,

I'm using the code below to search data in a DataTable, How do I sort the results by SN?

Dim SearchCriteria As String = "Substring(SN, 1,3) IN (" & xyz & " )"

                Dim FilteredDTA As DataTable
                Dim DVA As New DataView(dtsetLinkAOP6A.Tables(0), SearchCriteria, Nothing, DataViewRowState.CurrentRows)
                FilteredDTA = DVA.ToTable
                If FilteredDTA.Rows.Count > 0 Then

                    C1Screen1.Columns(0).Visible = True
                    Me.C1Screen1.DataSource = FilteredDTA.DefaultView.ToTable(True, New String() {"SN", "AGD", "CA"})
                    Me.C1Screen1.Columns("SN").Width = 60
                    Me.C1Screen1.Columns("AGD").Width = 500
                    Me.C1Screen1.Columns("CA").Width = 350
                Else
                    MsgBox("No Records Found")

                End If

Thanks,

Victor
0
Comment
Question by:vcharles
[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
6 Comments
 
LVL 40
ID: 39881766
I di not test, but I would try sorting the DataView before using it to create a table.

DVA.Sort = "SN"
0
 

Author Comment

by:vcharles
ID: 39882456
Hi,

Unfortunately it does not work.

Thanks,

Victor
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39882805
Looking at the documentation for the Sort property, I suspect you need to add either "ASC" or "DESC" in addition to the column name.

e.g.

DVA.Sort = "SN ASC"

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39882813
Could it be problem related to you trying to sort numeric values in a string column?
0
 

Author Closing Comment

by:vcharles
ID: 39882823
Thank You.
0
 

Author Comment

by:vcharles
ID: 39882832
It worked with DVA.Sort = "SN ASC".

Thanks,

V.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

770 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