Board index » delphi » ADOX, creating indexes

ADOX, creating indexes

I try to create a primary key for an Access 2000 DB using the imported ADOX
type library. The following code snippet causes a syntax error saying that
"no value can be assigned to a ReadOnly property".

The snippet from the type library (showing the _Index section) looks to me
as these properties should not be ReadOnly. At which point should I modify
the type library unit, so that I can assign values to these properties. Are
there other solutions ??

    idx_Primary : _Index;


idx_Primary := CoIndex.Create;
  with idx_Primary do begin
              Name := 'PrimaryKey';
              Primary := True;
              Unique := True;

Snippet from the type library unit (ADOX_tlb.pas):

  // *********************************************************************//
  _Index = interface(IDispatch)
    function Get_Name: WideString; safecall;
    procedure Set_Name(const pVal: WideString); safecall;
    function Get_Clustered: WordBool; safecall;
    procedure Set_Clustered(pVal: WordBool); safecall;
    function Get_IndexNulls: AllowNullsEnum; safecall;
    procedure Set_IndexNulls(pVal: AllowNullsEnum); safecall;
    function Get_PrimaryKey: WordBool; safecall;
    procedure Set_PrimaryKey(pVal: WordBool); safecall;
    function Get_Unique: WordBool; safecall;
    procedure Set_Unique(pVal: WordBool); safecall;
    function Get_Columns: Columns; safecall;
    function Get_Properties: Properties; safecall;
    property Name: WideString read Get_Name write Set_Name;
    property Clustered: WordBool read Get_Clustered write Set_Clustered;
    property IndexNulls: AllowNullsEnum read Get_IndexNulls write
    property PrimaryKey: WordBool read Get_PrimaryKey write Set_PrimaryKey;
    property Unique: WordBool read Get_Unique write Set_Unique;
    property Columns: Columns read Get_Columns;
    property Properties: Properties read Get_Properties;

  // *********************************************************************//
  // DispIntf:  _IndexDisp
  // Flags:     (4544) Dual NonExtensible OleAutomation Dispatchable
  // GUID:      {0000061F-0000-0010-8000-00AA006D2EA4}
  // *********************************************************************//
  _IndexDisp = dispinterface
    property Name: WideString dispid 0;
    property Clustered: WordBool dispid 1;
    property IndexNulls: AllowNullsEnum dispid 2;
    property PrimaryKey: WordBool dispid 3;
    property Unique: WordBool dispid 4;
    property Columns: Columns readonly dispid 5;
    property Properties: Properties readonly dispid 6;

Any hints are greatly appreciated.

Thomas Glden

Bayerisches Geologisches Landesamt
He?stra?e 128
80797 Mnchen



Re:ADOX, creating indexes

<<Thomas Gulden:
  with idx_Primary do begin
              Name := 'PrimaryKey';
              Primary := True;
              Unique := True;


In the snippet you gave, there is no 'Primary'
property, only 'PrimaryKey', so it should be
  PrimaryKey := True;
If I copy your code with just that correction,
it works fine for me - but I'm using Access 97.

Deborah Pate

Other Threads