Sort order Problem with datatable.select method

  • Thread starter Thread starter emailtonitin
  • Start date Start date
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.
 
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
 
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
 
Back
Top