当前位置: 首页 > 网络学院 > 服务端脚本教程 > ADO > ADO记录排序
We may use SQL to specify how to sort the data in the record set.
我们可以使用SQL来指明每条记录中数据的排列顺序
Sort the records on a specified fieldname ascending
将记录中指定的字段名按升序排列
How to sort the data on a specified fieldname.
如何将数据按照指定的字段名进行排列。
Sort the records on a specified fieldname descending
将记录中指定的字段名按降序排列
How to sort the data on a specified fieldname.
如何将数据按照指定的字段名进行排列。
Let the user choose what column to sort on
让用户选择需要对哪一纵列进行排列
Let the user choose what column to sort on.
让用户选择需要对哪一纵列进行排列
We want to display the "Companyname" and "Contactname" fields from the "Customers" table, ordered by "Companyname" (remember to save the file with an .asp extension):
我们希望对“Customers”表格中的名为"Companyname" 和"Contactname"的字段所对应的数据以"Companyname"字段名开头字母的顺序为基准进行排列(记住:使用“.asp”扩展名保存文件):
<html> <% set rs = Server.CreateObject("ADODB.recordset") </body> |
Here is the result:
输出结果:
Companyname | Contactname |
---|---|
Alfreds Futterkiste | Maria Anders |
Berglunds snabbköp | Christina Berglund |
Centro comercial Moctezuma | Francisco Chang |
Ernst Handel | Roland Mendel |
FISSA Fabrica Inter. Salchichas S.A. | Diego Roel |
Galería del gastrónomo | Eduardo Saavedra |
Island Trading | Helen Bennett |
Königlich Essen | Philip Cramer |
Laughing Bacchus Wine Cellars | Yoshi Tannamuri |
Magazzini Alimentari Riuniti | Giovanni Rovelli |
North/South | Simon Crowther |
Paris spécialités | Marie Bertrand |
Rattlesnake Canyon Grocery | Paula Wilson |
Simons bistro | Jytte Petersen |
The Big Cheese | Liz Nixon |
Vaffeljernet | Palle Ibsen |
Wolski Zajazd | Zbyszek Piestrzeniewicz |