什么意思?
如果排序 sort

解决方案 »

  1.   

    我见ado有一个方法seek,但不知怎么用。
    如我有一个MDB库有一个表main中建了一个索引,在ado中能用这个索引吗?
      

  2.   

    我见ado有一个方法seek,但不知怎么用。
    如我有一个MDB库有一个表main中建了一个索引,在ado中能用这个索引吗? 
      

  3.   

    看看這個例子對你有沒有用?Sub SeekX()   Dim dbsNorthwind As Database
       Dim rstProducts As Recordset
       Dim intFirst As Integer
       Dim intLast As Integer
       Dim strMessage As String
       Dim strSeek As String
       Dim varBook As Variant   Set dbsNorthwind = OpenDatabase("Northwind.mdb")
       ' You must open a table-type Recordset to use an index, 
       ' and hence the Seek method.
       Set rstProducts = _
          dbsNorthwind.OpenRecordset("Products", dbOpenTable)   With rstProducts
          ' Set the index.
          .Index = "PrimaryKey"      ' Get the lowest and highest product IDs.
          .MoveLast
          intLast = !ProductID
          .MoveFirst
          intFirst = !ProductID      Do While True
             ' Display current record information and ask user 
             ' for ID number.
             strMessage = "Product ID: " & !ProductID & vbCr & _
                "Name: " & !ProductName & vbCr & vbCr & _
                "Enter a product ID between " & intFirst & _
                " and " & intLast & "."
             strSeek = InputBox(strMessage)         If strSeek = "" Then Exit Do         ' Store current book in case the Seek fails.
             varBook = .Book         .Seek "=", Val(strSeek)         ' Return to the current record if the Seek fails.
             If .NoMatch Then
                MsgBox "ID not found!"
                .Book = varBook
             End If
          Loop      .Close
       End With   dbsNorthwind.CloseEnd Sub
      

  4.   

    以下是adohelp中的说明:
    Seek 方法
          搜索 Recordset 的索引,快速定位与指定值相匹配的行,并将当前行更改为该行。语法recordset.Seek KeyValues, SeekOption参数KeyValues   VARIANT 值的数组。索引由一个或多个列组成,而数组包含与每个对应列进行比较的值。 SeekOption    SeekEnum 只值,指定在索引的列和对应的 KeyValues 之间进行的比较的类型。可以是如下某个比较常量:常量 说明 
    AdSeekAfterEQ 查找等于 KeyValues 的关键字,或仅在已经匹配过的位置之后进行查找。 
    AdSeekAfter 仅在已经有过与 KeyValues 匹配的位置之后进行查找。 
    AdSeekBeforeEQ 查找等于 KeyValues 的关键字,或仅在已经匹配过的位置之前进行查找。 
    AdSeekBefore 仅在已经有过与 KeyValues 匹配的位置之前进行查找。 
    AdSeekFirstEQ 查找等于 KeyValues 的第一个关键字。 
    AdSeekLastEQ 查找等于 KeyValues 的最后一个关键字。 
    说明如果基本提供者支持对 Recordset 对象使用索引,请结合 Index 属性使用 Seek 方法。请使用 Supports (adIndex) 方法判断基本提供者是否支持索引。如果 Seek 没有找到想要的行,则不发生错误,并且行被定位于 EOF。请在执行该方法之前,将 Index 属性设置为所需索引。该方法只能用于当 Recordset 对象的 CursorLocation 属性的值不是 adUseClient 时。
    另:
    Index 属性
          指示对 Recordset 对象当前生效的索引的名称。设置和返回值设置或返回字符串值,该值为索引名。说明由 Index 属性命名的索引必须针对基本表基本 Recordset 对象已在前面声明过。即索引必须已在程序中声明为 ADOX Index 对象,或在创建基本表时声明。如果无法设置索引,则会发生运行时错误。无法在 WillRecordsetChange 或 RecordsetChangeComplete 事件处理程序内设置 Index 属性。如果 Recordset 正在执行操作,也无法对它进行设置。如果 Recordset 是关闭的,则总能成功设置 Index 属性,但如果基本提供者不支持索引,则 Recordset 将无法成功打开,或者索引将无法使用。如果可以设置索引,则可以更改当前行的位置。这将导致对 AbsolutePosition 属性的更新,并产生 WillRecordsetChange、RecordsetChangeComplete、WillMove 和 MoveComplete 事件。如果可以设置索引,而 LockType 属性是 adLockPessimistic 或 adLockOptimistic,那么,将执行隐式 UpdateBatch 操作,并释放当前的和受影响的组。任何现有的 filter 被释放,并且当前行位置更改为重排序后 Recordset 的第一行。Index 属性与 Seek 方法连通使用。如果基本提供者不支持 Index 属性和 Seek 方法,请考虑使用 Find 方法替代。使用 Supports(adIndex) 方法可判定 Recordset 对象是否支持索引。尽管二者均处理索引,但内置的 Index 属性与动态的 Optimize 属性无关。注:我觉得帮助文件中的说明可以满足你的要求。