VB 怎样对ACCESS数据库排序

2025-01-20 02:51:25
推荐回答(2个)
回答1:

1、select * from table order by 字段 desc
这是按此字段的降序排.
2、select * from table order by 字段 asc
这是按升序排.
3、举个例子:
Public Sub SortX()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset

rst.CursorLocation = adUseClient
cnn.Open "DSN=Pubs;Provider=MSDASQL;uid=sa;pwd=;"
rst.Open "SELECT * FROM Authors", cnn, _
adOpenStatic, adLockReadOnly, adCmdText
SortXprint "Initial Order", rst

rst.Sort = "au_lname ASC, au_fname ASC"
SortXprint "Last Name Ascending", rst

rst.Sort = "au_lname DESC, au_fname ASC"
SortXprint "Last Name Descending", rst

rst.Close
cnn.Close
End Sub
再将rst写入新表,删除原表,将新表定为原表名即可

回答2:

这个相关的问题今天我回了好几次了,汗~~

参考这个吧:

http://zhidao.baidu.com/question/75104660.html