Solved

Dataset Sort VB>net

Posted on 2010-08-27
3
418 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Server memory Issue 7 74
Convert to Hour/minute textbox and compare 3 36
Copy/Clone an object. 9 15
SQL BACKUP - 2008 R2 8 12
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

758 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

18 Experts available now in Live!

Get 1:1 Help Now