Board index » delphi » DbiAddIndex problems

DbiAddIndex problems

Here's my code.  I've got a table (Registrants_) that already has the 1st 2
fields as primary indexes.  I want to make the third field part of the
primary as well.  I copied the following code from the BDE help example.  I
keep getting an invalid index error on the "check" line.  Anybody know
what's going on?

Thanks!

               NewIndex.iIndexId:=   0;
               NewIndex.bPrimary:=   TRUE;
               NewIndex.bUnique:=   TRUE;
               NewIndex.bDescending:=  FALSE;
               NewIndex.bMaintained:=  TRUE;
               NewIndex.bSubset:=   FALSE;
               NewIndex.bExpIdx:=   FALSE;
               NewIndex.iFldsInKey:=  3;
               NewIndex.aiKeyFld[0]:=  1;
//               NewIndex.aiKeyFld[1]:=  2;
//               NewIndex.aiKeyFld[2]:=  3;

               Registrants_.Active:=true;
//               Registrants_.Active:=false;
               Check(DbiAddIndex(Registrants_.dbhandle, Registrants_.handle,
PChar(Registrants_.TableName),szParadox, NewIndex, nil));

 

Re:DbiAddIndex problems


Never mind!  I figured it out!  EUREKA! :)

Quote
Michael J. Quinn wrote in message <6vum9m$es...@forums.borland.com>...
>Here's my code.  I've got a table (Registrants_) that already has the 1st 2
>fields as primary indexes.  I want to make the third field part of the
>primary as well.  I copied the following code from the BDE help example.  I
>keep getting an invalid index error on the "check" line.  Anybody know
>what's going on?

>Thanks!

>               NewIndex.iIndexId:=   0;
>               NewIndex.bPrimary:=   TRUE;
>               NewIndex.bUnique:=   TRUE;
>               NewIndex.bDescending:=  FALSE;
>               NewIndex.bMaintained:=  TRUE;
>               NewIndex.bSubset:=   FALSE;
>               NewIndex.bExpIdx:=   FALSE;
>               NewIndex.iFldsInKey:=  3;
>               NewIndex.aiKeyFld[0]:=  1;
>//               NewIndex.aiKeyFld[1]:=  2;
>//               NewIndex.aiKeyFld[2]:=  3;

>               Registrants_.Active:=true;
>//               Registrants_.Active:=false;
>               Check(DbiAddIndex(Registrants_.dbhandle,

Registrants_.handle,

- Show quoted text -

Quote
>PChar(Registrants_.TableName),szParadox, NewIndex, nil));

Re:DbiAddIndex problems


Quote
>Here's my code.  I've got a table (Registrants_) that already has the 1st 2
>fields as primary indexes.  I want to make the third field part of the
>primary as well.  I copied the following code from the BDE help example.  I
>keep getting an invalid index error on the "check" line.  Anybody know
>what's going on?

First you need to remove the existing primary index.  You can do this with SQL
Drop Index query

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Re:DbiAddIndex problems


I was able to do it without dropping the primary index.
If any body wants the code, I'll post it.

Quote
Brian Bushay TeamB wrote in message <362905c0.75890236@floyd>...

>>Here's my code.  I've got a table (Registrants_) that already has the 1st
2
>>fields as primary indexes.  I want to make the third field part of the
>>primary as well.  I copied the following code from the BDE help example.
I
>>keep getting an invalid index error on the "check" line.  Anybody know
>>what's going on?

>First you need to remove the existing primary index.  You can do this with
SQL
>Drop Index query

>--
>Brian Bushay (TeamB)
>Bbus...@DataGuidance.com

Other Threads