Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dataset Sort VB>net

Posted on 2010-08-27
3
Medium Priority
?
428 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
[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
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 2000 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

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 post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

715 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