Index in ADO 
Author Message
 Index in ADO

Do you know what is the Index property for ADO recordset?

Thnaks in advance for your help,

Mon, 23 Aug 2004 01:24:59 GMT  
 Index in ADO
Hi Eduardo,

The Index property of the ADO Recordset indicates the name of the index
currently in effect for the specific Recordset object. You could use this
property to set an index to to get the current index that is set for the
given recordset object.

Here is more info from MSDN:

"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:

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 the generation of
WillChangeRecordset, RecordsetChangeComplete, WillMove, and MoveComplete

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

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."

Now, one thing I would like to add is that most OLEDB providers (including
Microsoft OLEDB Provider for SQL Server) don't support the seek method and
thus they don't support the above mentioned Index property.

You could run the following code on your recordset before using this
property to check if your recordset supports it or not:
bool valBool = spRS->Supports(adIndex);

If the above line returns false (or 0), then this is not supported by your

Hope this helps...

Ammar Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit

Mon, 23 Aug 2004 08:43:39 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Access2000 Key Index in ADO?

2. index files by VFPODBC, MSDASQL, and ADO from C++

3. array indexing by pointer and long index

4. indexed sequential, indexed, inverted, hash or direct file support

5. ADO.NET sure is long-winded compared to old ADO

6. how to display data source in several pages in like i do in ado

7. Much ADO about nothing?--Oracle BLOBs and ADO 2.0

8. ODBC-SDK, DAO, ADO ? // ADO: doc, version

9. ADO In ATL Project,ADO Version,CreateInstance Failed

10. ADO Data control bind to ADO DataGrid

11. Using ADO 2.1 / ADOX / ADO 2.0 with C++

12. ADO or not ADO?


Powered by phpBB® Forum Software