Upravit

Sdílet prostřednictvím


Index Property

Indicates the name of the index currently in effect for a Recordset object.

Settings and Return Values

Sets or returns a String value, which is the name of the index.

Remarks

The index named by the Index property must have previously been declared on the base table underlying the Recordset object. That is, the index must have been declared programmatically either as an ADOX Index object, or when the base table was created.

A run-time error will occur if the index cannot be set. The Index property cannot be set under the following conditions:

  • Within a WillChangeRecordset or RecordsetChangeComplete event handler.

  • If the Recordset is still executing an operation (which can be determined by the State property).

  • If a filter has been set on the Recordset with the Filter property.

The Index property can always be set successfully if the Recordset is closed, but the Recordset will not open successfully, or the index will not be usable, if the underlying provider does not support indexes.

If the index can be set, the current row position may change. This will cause an update to the AbsolutePosition property, and will fire the WillChangeRecordset, RecordsetChangeComplete, WillMove, and MoveComplete events.

If the index can be set and the LockType property is adLockPessimistic or adLockOptimistic, then an implicit UpdateBatch operation is performed. This releases the current and affected groups. Any existing filter is released, and the current row position is changed to the first row of the reordered Recordset.

The Index property is used in conjunction with the Seek method. If the underlying provider does not support the Index property, and thus the Seek method, consider using the Find method instead. Determine whether the Recordset object supports indexes with the Supports(adIndex) method.

The built-in Index property is not related to the dynamic Optimize property, although they both deal with indexes.

Applies To

Recordset Object (ADO)

See Also

Seek Method and Index Property Example (VB)
Index Object (ADOX)
Seek Method