Sort order Problem with datatable.select method

E

emailtonitin

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.
 
B

Brock Allen

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.
 
N

nitin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top