怎麽对 RecordSet 中的数据进行排序和过滤
当我用 rst.sort 对记录集中的某个字段进行排序时系统提示。。。。
-------------------------------------------
错误 3251
当前提供程序不支持排序或过滤必需的界面
-------------------------------------------
这是什麽错误??应该怎麽解决??
[解决办法]
我这边怎么可以啊:
参考:
Option Explicit
Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Private Sub Command1_Click()
If Not Cnn Is Nothing Then
Set Rs = New ADODB.Recordset
Rs.Open "select top 10 * from region ", Cnn, adOpenDynamic, adLockOptimistic
End If
Set DataGrid1.DataSource = Rs
End Sub
Private Sub Command2_Click()
If Rs.Sort <> "cregionCode Desc " Then
Rs.Sort = "cregionCode Desc "
Else
Rs.Sort = "cregionCode Asc "
End If
End Sub
Private Sub Form_Load()
Set Cnn = New ADODB.Connection
Cnn.CursorLocation = adUseClient
Cnn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=数据库名;Data Source=服务器名 "
Cnn.Open
End Sub
Private Sub Form_Unload(Cancel As Integer)
Rs.Close
Set Rs = Nothing
Cnn.Close
Set Cnn = Nothing
End Sub