Re: Sorted data is not sorted



I don't think Select looks at the deafault view's sort. It just works with
the underlying order of the rows.

Use a dataview as your datasource, and put a filter on it.

But, if you say you prefer to have your data be sorted by the stored
procedure, why not do that? If you can have the database do the sorting, you
should.

"AMDRIT" <amdrit@xxxxxxxxxxx> wrote in message
news:uDLQxUb1FHA.2072@xxxxxxxxxxxxxxxxxxxxxxx
>I have a table [CoverageLimits] with the following columns
>
> Coverage, Limit, LimitDescription, PerPerson, PerAccident
>
> I load the data from a stored procedure into a datatable
>
> Select Coverage, Limit, LimitDescription, PerPerson, PerAccident From
> CoverageLimits Order By Coverage, PerPerson, PerAccident.
>
> I have manually executed this procedure in Query Analyzer and the data
> comes out in the desired order.
>
> 'A', 'J', '20/40', 20, 40
> 'A', 'K', '25/50', 25, 50
> 'A', 'C', '100/300', 100, 300
>
> While the data is actually stored in the heap in this order
>
> 'A', 'K', '25/50', 25, 50
> 'A', 'C', '100/300', 100, 300
> 'A', 'J', '20/40', 20, 40
>
> When I attempt to populate a combobox with this data from my datatable
>
> dim drs() as datarow
>
> drs = mydatatable.select("Coverage = '" & A & "'")
>
> cbo.DataSource = drs
> cbo.DisplayMember = "LimitDescription"
> cbo.ValueMember = "Limit"
>
> The data is displayed in its natural ordered state. So then I attempted
> to sort the data in the table
>
> dim drs() as datarow
> mydatatable.defaultview.sort = "Coverage, PerPerson, PerAccident"
> drs = mydatatable.select("Coverage = '" & A & "'")
>
> cbo.DataSource = drs
> cbo.DisplayMember = "LimitDescription"
> cbo.ValueMember = "Limit"
>
> The data is still displayed in its natural ordered state. Now I can
> attempt to sort the array of datarows, but this seems kind of a wasted
> step, I would prefer the data be ordered by my stored procedure.
>
> Anyone have any ideas how I can achieve the desired result?
>
> TIA
>


.



Relevant Pages

  • Re: Sorted data is not sorted
    ... The fix for me was to use the dataview. ... >> Select Coverage, Limit, LimitDescription, PerPerson, PerAccident From ... >> dim drs() as datarow ... I would prefer the data be ordered by my stored procedure. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: ORDER BY in VIEW not working
    ... Table - by definition, no sort order allowed. ... Stored Procedure - Testing shows that ... ... compromise to allow a stored procedure to return an ordered set, ... compromise whereby a view could also return an ordered set. ...
    (comp.databases.ms-sqlserver)
  • Re: expanding a stored proc that is already beyond me
    ... >> I need to expand this stored procedure which is already beyond my current ... and which direction to sort in.. ... SELECT MainID, Title, ShortDesc, Priority, EstimatedDeliveryDate, ... >> EstimatedDeliveryDate END ASC, ...
    (microsoft.public.sqlserver.programming)
  • Re: Sorting in GridView problem
    ... My stored procedure will return the data in the correct sort order ... clicked column isn't being passed to the select function that calls the ... >> an ObjectDataSource that uses a stored procedure to return the data. ... >> * In the gridviews OnSorting event handler, ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: expanding a stored proc that is already beyond me
    ... I use the following stored procedure to bind data ... It handles getting the data and which field to sort ... > SELECT MainID, Title, ShortDesc, Priority, EstimatedDeliveryDate, ... > EstimatedDeliveryDate END ASC, ...
    (microsoft.public.sqlserver.programming)