dataset and sort

  • Thread starter Thread starter Sehboo
  • Start date Start date
S

Sehboo

I call a stored procedure and get the data in dataset then I do this
to sort my data
myDS.Tables[0].Select("" , "terminal DESC");

but it doesn't sort. If I put something in filter then it totally
ignors that as well...am I missing something?
 
You gotta set a variable to the results


DataRow [] rows = ds.Tables[0].Select("" , "terminal DESC");

then loop on the rows, cast them if necessary (for a strongly typed dataset)
 
Sehboo,

Instead of calling Select, you should use a DataView and set the Sort
property to "terminal DESC".
 
I tried this as well
myDS.Tables[0].DefaultView.Sort = "terminal DESC";

but it ignores it too. It always shows the data in the order which
was returned by stored procedure. I am trying to overwrite it.

Sehboo,

Instead of calling Select, you should use a DataView and set the Sort
property to "terminal DESC".

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I call a stored procedure and get the data in dataset then I do this
to sort my data
myDS.Tables[0].Select("" , "terminal DESC");
but it doesn't sort. If I put something in filter then it totally
ignors that as well...am I missing something?- Hide quoted text -

- Show quoted text -
 
Sehboo,

This is what a DataView is for. You shouldn't use the DefaultView
property, but create a new DataView.

The reason it doesn't work when setting the property on the DefaultView
is because you have to access the DefaultView, not the DataSet to get the
sorted results. Manipulating the DefaultView is usually not a good idea.

Basically, create a new instance of the DataView class and pass that
around after you set the sort, and work with that.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Sehboo said:
I tried this as well
myDS.Tables[0].DefaultView.Sort = "terminal DESC";

but it ignores it too. It always shows the data in the order which
was returned by stored procedure. I am trying to overwrite it.

Sehboo,

Instead of calling Select, you should use a DataView and set the Sort
property to "terminal DESC".

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I call a stored procedure and get the data in dataset then I do this
to sort my data
myDS.Tables[0].Select("" , "terminal DESC");
but it doesn't sort. If I put something in filter then it totally
ignors that as well...am I missing something?- Hide quoted text -

- Show quoted text -
 
Back
Top