CreateIndex Method

See Also    Example    Applies To

Creates a new CdbIndex object (Microsoft Jet workspaces only).

Syntax

CdbIndexCreateIndex(LPCTSTR pstrName = NULL);

Parameters

Type Example Description
LPCTSTR pstrName = NULL Optional. A pointer to a string that uniquely names the new CdbIndex object. See the Name property for details on valid CdbIndex names.

Remarks

You can use the CreateIndex method to create a new CdbIndex object for a CdbTableDef object. If you omit the optional name part when you use CreateIndex, you can use an appropriate assignment statement to set or reset the Name property before you append the new object to a collection. After you append the object, you may or may not be able to set its Name property, depending on the type of object that contains the Indexes collection. See the Name property topic for more details.

If pstrName refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a CdbIndex object from a collection, use the Delete method on the collection.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbIndex      idx;
CdbTableDef      td;
...                           // Initialize td, etc.
idx = td.CreateIndex(   _T("CarPartsIdx"));