对数据集进行排序 [英] Sorting a dataset

查看:76
本文介绍了对数据集进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以对数据集而不是数据视图进行排序?我有一个web

服务,它返回一个数据集,我想在它返回之前对它进行排序(这是因为排序是标准化的,所以
$ b将结果视为xml的$ b应用程序不必捣乱

并在以后自行排序。


我尝试对数据视图进行排序并将该数据视图的表添加到数据集中,但结果不会保持排序。我可以看到这样做的唯一方法是返回数据视图而不是数据集(由于各种原因我不想做b $ b)。


有没有人能解决这个问题?


非常感谢。

Is it possible to sort a dataset rather than a dataview? I have a web
service that returns a dataset which I would like to sort before
returning it (this is so the sorting is standardised and so
applications that see the results as xml don''t have to fiddle around
and sort it themselves later).

I have tried sorting a dataview and adding that dataview''s table to
the dataset but the results don''t remain sorted. The only way I can
see to do it is if I return a dataview rather than a dataset (which I
don''t want to do for various reasons).

Does anyone have a solution to this problem?

Many thanks.

推荐答案

您好Nikki,


我认为最好的办法是使用数据视图进行排序,而不是使用

来制作逐行浏览数据视图的新数据集。


您可能需要的是

dataset.clone

datatable。 importrow


(我不确定你是否可以使用最后一个,但我认为你可以试试

)。

我希望这有帮助吗?


Cor
Hi Nikki,

I think the best thing to do is to use a dataview to sort and than use that
to make a new dataset by going through that dataview row by row.

What you need probably are
dataset.clone
datatable.importrow

(I am not sure if you can use the last one however I think that you can try
it).

I hope this helps?

Cor


我在VB.net中通过创建数据表来执行此操作然后,数据集的副本将清除数据集,并使用允许过滤和排序的select命令将数据表合并回(已清除)数据集。但是,一旦您将任何数据更新回数据库,排序就会丢失,数据库只不过是坚果(数据)。如果这是正确的路径,我可以在讨论中添加一些代码。

希望它有所帮助,约翰


" Nikki"写道:
I do this in VB.net by creating a datatable as a copy of the dataset then clear the dataset and merge the datatable back into the (cleared) dataset using the select command which allows filtering and sorting. BUT, once you update any data back to a database, the sort is lost, the database is nothing more than a sacck of nuts (data). If this is heading in the right path I can add some code to the discussion.
Hope it helps, John

"Nikki" wrote:
是否可以对数据集而不是数据视图进行排序?我有一个web
服务,它返回一个数据集,我想在它返回之前对它进行排序(这样排序是标准化的,因此应用程序将结果视为xml don''我必须摆弄它们并稍后自行排序。

我已经尝试对数据视图进行排序并将数据视图的表添加到数据集中,但结果不是不会排序。我可以看到这样做的唯一方法是,如果我返回数据视图而不是数据集(由于各种原因我不想做)。

有没有人能解决这个问题?

非常感谢。
Is it possible to sort a dataset rather than a dataview? I have a web
service that returns a dataset which I would like to sort before
returning it (this is so the sorting is standardised and so
applications that see the results as xml don''t have to fiddle around
and sort it themselves later).

I have tried sorting a dataview and adding that dataview''s table to
the dataset but the results don''t remain sorted. The only way I can
see to do it is if I return a dataview rather than a dataset (which I
don''t want to do for various reasons).

Does anyone have a solution to this problem?

Many thanks.



Nikki,

我在填写DataTable之前会对数据库进行排序(订单

在您的Select语句中)。


或者您可以尝试设置主键DataTable到您想要的

排序顺序。我不记得这是否有所作为...


希望这有帮助

Jay

"尼克" < NI ***** @ talk21.com>在消息中写道

新闻:8d ************************** @ posting.google.c om ...
Nikki,
I would do the sort on the database before filling the DataTable (an Order
By on your Select statement).

Alternatively you may try setting the primary key of the DataTable to the
sort order you want. I don''t remember if that makes a difference or not...

Hope this helps
Jay
"Nikki" <ni*****@talk21.com> wrote in message
news:8d**************************@posting.google.c om...
是否可以对数据集而不是数据视图进行排序?我有一个web
服务,它返回一个数据集,我想在它返回之前对它进行排序(这样排序是标准化的,因此应用程序将结果视为xml don''我必须摆弄它们并稍后自行排序。

我已经尝试对数据视图进行排序并将数据视图的表添加到数据集中,但结果不是不会排序。我可以看到这样做的唯一方法是,如果我返回数据视图而不是数据集(由于各种原因我不想做)。

有没有人能解决这个问题?

非常感谢。
Is it possible to sort a dataset rather than a dataview? I have a web
service that returns a dataset which I would like to sort before
returning it (this is so the sorting is standardised and so
applications that see the results as xml don''t have to fiddle around
and sort it themselves later).

I have tried sorting a dataview and adding that dataview''s table to
the dataset but the results don''t remain sorted. The only way I can
see to do it is if I return a dataview rather than a dataset (which I
don''t want to do for various reasons).

Does anyone have a solution to this problem?

Many thanks.



这篇关于对数据集进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆