Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dataset Sort VB>net

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

886 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