Solved

Dataset Sort VB>net

Posted on 2010-08-27
3
420 Views
Last Modified: 2012-05-10
I am sure this has been answered a jillion times but i have looked and am not finding answers to my case -

i have a dataset i load up to pull data from while a user navigates the dataset.

if the user wants to sort the default load of the query, i would like to allow him to with the currently loaded dataset and not re-querying the actual database since his computer is super slow to begin with.

i put the basic dataset load below - basically want objds.tables("contacts").defaultview.sort = "LName DESC"

execute?!??!
objcon.Open()
        objDA = New OleDb.OleDbDataAdapter(strSQL, objcon)
        objDA.Fill(objDS, "Contacts")

        maxRows = objDS.Tables("Contacts").Rows.Count
        objcon.Close()

Open in new window

0
Comment
Question by:nosehead2000
3 Comments
 
LVL 15

Expert Comment

by:dave4dl
ID: 33547529
use the defaultView (see
http://weblogs.asp.net/jcogley/archive/2003/09/15/27567.aspx)
You could also use the "Select" command (which will return a sorted array of dataRows).  See http://msdn.microsoft.com/en-us/library/way3dy9w.aspx
0
 
LVL 5

Expert Comment

by:FredTang
ID: 33553553
strSql="select * from yourTableName order by Lname desc "
0
 
LVL 1

Accepted Solution

by:
Jacob_Iedema earned 500 total points
ID: 33564831
You can create a dataview:

dtView = New DataView(dtTable, "", "fieldsort", DataViewRowState.CurrentRows)

After that you can bind the dataview to a control or cycle the rows in code like this:

        Dim dRow As DataRowView

        For Each dRow In dtView

                .....do stuff
        Next



0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

776 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