473,231 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Is there method to sort my dataset table with one or mulitple colu

Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Jan 31 '07 #1
3 1848
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #2
I want to pass a sorted dataset table to Crystal Report becuase I think it
might give better performance. I don't think that dataview can be passed as
a datasource to crystal and the sorted result isn't saved to the dataset
table either, right?
--
Thanks.
"Jason Vermillion" wrote:
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #3

I think you can pass a DataView to setdatasource(). I've not tested it
myself but see this post:
http://forums.microsoft.com/MSDN/Sho...70964&SiteID=1

I know there used to be a bug with SetDataSource() and you had to sort the
data in a DataView then copy it back into a clone of the original DataTable.
I think this has long been fixed though. The workaround went something like
this:

System.Data.DataTable origTbl; // Your original table
DataView dv;
System.Data.DataTable sortedTbl;

dv = origTbl.DefaultView;
dv.Sort = "col1 asc, col2 asc";

// Copy the sorted view into a new table..
sortedTbl = dv.Table.Clone();
for (int i = 0; i < dv.Count; i++)
{
sortedTbl.ImportRow(dv[i].Row);
}

Hope this helps,
Jason Vermillion
"Pucca" wrote:
I want to pass a sorted dataset table to Crystal Report becuase I think it
might give better performance. I don't think that dataview can be passed as
a datasource to crystal and the sorted result isn't saved to the dataset
table either, right?
--
Thanks.
"Jason Vermillion" wrote:
Pucca,

You can do it a couple of different ways. You'll find a lot of good
examples from a Google for DataTable.Select or DataView.Sort.

Most folks use System.Data.DataView.Sort since the results are a bit easier
to deal with than the array that DataTable.Select() returns.

see this article:
http://www.akadia.com/services/dotnet_filter_sort.html

Jason Vermilllion

"Pucca" wrote:
Are there any good built-in or availble functions that I can call to sort my
dataset datatalbe based on 1 or more of the table's columns?
--
Thanks.
Feb 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
3
by: Fungi2003 | last post by:
I am binding a datagrid to a dataset but there are some columns I don't want show in the dataset, what is the easiest way of removing these columns yet still binding to that dataset?
5
by: moondaddy | last post by:
I'm writing an winforms app in vb.net 1.1 and am having trouble referencing a strongly typed dataset in the UI project. The dataset's source is behind a web service and the data project (client...
1
by: JohnR | last post by:
I'm using oledb to an Access datatable. I load the table into a dataset. I create databindings to link the fields on my form to the corresponding fields in the datatable. The tables...
4
by: Terry | last post by:
Hi, I am both new to .Net (coming from VB6 and DAO) and to this news group. I am trying to convert some code from VB6 that uses a "record set" to help the user locate a specific record. As the...
3
by: joey.powell | last post by:
I have a datagridview where I set its "DataSource" property to a DataSet and its "DataMember" property to a table within the DataSet. I need for the DataGridView to "sort" through the contents of...
12
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
1
by: Aeric | last post by:
I have read the following topic: sorting dataset and I am facing the same issue. I am designing a report. I have fill a dataset with the results from a query. From the results, I used to set...
3
by: leviwatts | last post by:
Exception Details: System.ArgumentException: DataTable already belongs to another DataSet. Googling for this error shows several post of people trying to manipulate a table within a dataset. Others...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.