在VB中我们曾经能够打开一个ACCESS DAO.Recordset并指定一个索引。打开后,我们可以在索引中寻找特定记录,然后使用索引从那里向后和向前遍历数据集。
Dim dnj As DAO.Recordset
dnj = DB.OpenRecordset("ITEMS")
dnj.Index = "IndexIW"
dnj.Seek("=", "Item 17a", "ABC")
dnj.MovePrevious()
现代数据库中是否有类似SQL Server使用索引来读取记录?我尝试了这个,但错误说不支持索引的API。
Dim iTbl As New ADODB.Recordset
Dim key(1) As String
iTbl.ActiveConnection = cnn
iTbl.CursorLocation = ADOR.CursorLocationEnum.adUseServer
iTbl.Open("ITEMS")
iTbl.Index = "IndexIW"
key(0) = "Item 17a"
key(1) = "ABC"
iTbl.Seek(key, ADODB.SeekEnum.adSeekFirstEQ)
iTbl.MovePrevious()
我真正希望能做的是:
SELECT NEXT 10 ITEM_NUM, ITEM_TYPE, ITEM_DESC FROM ITEMS WHERE (PK_ITEM) = ("Item 17a","ABC")
或
SELECT TOP 10 ITEM_NUM, ITEM_TYPE, ITEM_DESC FROM ITEM STARTING WITH PK_ITEM = ("Item 17a","ABC")
但我不知道该怎么做