473,321 Members | 1,669 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,321 software developers and data experts.

Sort order Problem with datatable.select method

Hi,

I am having a problem with the default sorting mechanism employed by
the datatable.select method -

I have a datatable having rows (simplified for clarity) -
name
-----
c
a
b
f
d
e
Now, if I select some rows from a datatable -
datatable.select ("name in 'c,a,b'")

but the rows are returned in the order -
a
b
c

seems like there is some default sorting taking place inside the
function. I would like to know if it is possible to avoid it somehow,
so that the rows can be returned in the original order?

The datatable has no primary key defined.

Thanks for your help.

Nov 19 '05 #1
3 3666
Toni, how are the rows in the table indexed? Is there a primary key
column?

Jason Bentley
http://geekswithblogs.net/jbentley

Nov 19 '05 #2
Just like any database (or pseudo-database in the case of the DataSet) unless
you're explicit with an order by clause, you can never assume or rely upon
the order of the rows being returned.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

I am having a problem with the default sorting mechanism employed by
the datatable.select method -

I have a datatable having rows (simplified for clarity) -
name
-----
c
a
b
f
d
e
Now, if I select some rows from a datatable -
datatable.select ("name in 'c,a,b'")
but the rows are returned in the order -
a
b
c
seems like there is some default sorting taking place inside the
function. I would like to know if it is possible to avoid it somehow,
so that the rows can be returned in the original order?

The datatable has no primary key defined.

Thanks for your help.


Nov 19 '05 #3
I see.
My concern was the definition of datatable.select method in msdn -
"Gets an array of all DataRow objects that match the filter criteria in
order of primary key (or lacking one, order of addition.)"

In my case, in the absense of primary key, the data returned is not in
order of addition.
But I agree with Brock regarding not assuming things in this case.
Ok, will workaround this one.

Thank you, guys.

And, sorry about the cross-posting.

Nitin

Nov 19 '05 #4

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

Similar topics

2
by: Clinton Pierce | last post by:
I've filled a DataTable with columns that have custom type (a class that I'm using to keep track of other things, not just a value). When the .Select method goes to sort this column, how do I let...
6
by: Hardy Wang | last post by:
Hi, I have a DataSet, returned by a stored procudure, which has only on DataTable. At this step there is no sort in DataTable. Is there is a way I can do to sort DataRows in this DataTable (not...
1
by: Das | last post by:
hi, I'm using data grid with allow sort to true. So with user clicks the header of the column the data is sorted by the column. With the help of hittest I know that which column was last sorted...
5
by: Kurt Schroeder | last post by:
I'm using VS.net. I have created a component with the basic set of database commands. This component returns a record set that is bound to a datagrid. I want to add a dynamic sort, but am not sure...
5
by: Gene Hubert | last post by:
I'm using the DefaultView from the Datasource for a DataGrid to present the data in a particular order. It seems that sorting in this way is an "Active Sort", as is the default sort that is...
2
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having...
1
by: thomasp | last post by:
I want to use two SQL statements: Dim strSQLLCMR As String = "SELECT DTG, POO FROM LCMR WHERE (Confirmed = true and Friendly = False) ORDER BY DTG" Dim strSQLQ36 As String = "SELECT DTG, POO...
3
by: =?Utf-8?B?UHVjY2E=?= | last post by:
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.
2
by: Randy | last post by:
I have two listboxes on a form. The first box displays categories while the second box displays the items belonging to the category selected in the first box. Thus, the second box is essentially...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.