如何对数据库中的数据进行排序? [英] how to sort data from database?

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

问题描述

我正在制作一个小型应用程序...我有数据库,我需要使用气泡排序对数据库中的数据进行排序...我使用gridview来显示需要排序的数据...如何对数据库进行排序网格视图中的数据?...请帮助我...感谢

i am making a small application...i have database and i need to sort the data from my database using bubble sort...i use gridview to display the data i need to sort...how can i sort the data in a gridview?...please help me...thanks

推荐答案

如果您有数据库,请让它为您完成排序工作:添加一个用于检索数据的Select语句的"Order By"子句.

If you have a database, let it do the work of sorting for you: add an "Order By" clause to the Select statement that retrieves the data.

Select widget_name,widget_price from MywidgetTable Order by widget_price ASC


您不需要进行任何气泡排序.

如果是ASP.NET:
只需使用ASP.NET的排序功能即可在Gridview中对数据进行排序.此处的示例:
在GridView Web服务器控件中排序数据 [ ASP.NET 2.0的GridView示例:对GridView的数据进行分页和排序 [ ^ ]

如果是winforms:
在Windows窗体DataGridView控件中排序数据 [
You don''t need to do any bubble sorting.

If ASP.NET:
Just use the sorting feature of ASP.NET in order to sort data in Gridview. Samples here:
Sorting Data in a GridView Web Server Control[^]
GridView Examples for ASP.NET 2.0: Paging and Sorting the GridView''s Data[^]

If winforms:
Sorting Data in the Windows Forms DataGridView Control[^]


请参见 [
See this[^] article. It shows how to sort arrays.

This should give an idea to implement similar thing for gridview datasource as well.


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

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