Solved

Dataset Sort VB>net

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

734 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