Board index » delphi » Creating primary key for Access 97 tables

Creating primary key for Access 97 tables

Hi,

To create primary indexes for a set of tables in an Access 97 database I
used two methods with different results:

1.) Using the table.AddIndex('PrimaryKey','<keyfield(s)>',[ixPrimary]);
syntax worked in many examples, but at certain tables it stopped with the
EDBEngine exceptions ('Index already existing') or ('General SQL error).

2.) Replacing the AddIndex syntax with DAO methods after importing the
DAO-Typelibrary everything worked fine on the same tables with the same
parameters.

var
    DBE : _DBEngine;
    DB : Database_;

begin
    DBE := CoDBEngine_.Create;
    DB :=
DBE.OpenDatabase('<databasefile>',EmptyParam,EmptyParam,EmptyParam);
    DB.Execute('CREATE INDEX .....same parameters as in 1.  ....');
end;

Example 2 (just shows the principle, there may be syntactical errors here,
because the exact code is in the office) worked.

Questions:  Are there any limitations of adding a Primary Key to Access 97
tables using the VCL ?
                    Has the AddIndex method any problems ?

                    What is the safest code in VCL or others to add a
Primary Key to an Access 97 table.

Thanks in advance for any answers.

Thomas Glden

thomasgul...@csi.com

 

Re:Creating primary key for Access 97 tables


Quote
> 2.) Replacing the AddIndex syntax with DAO methods after importing the
> DAO-Typelibrary everything worked fine on the same tables with the same
> parameters.

Why not using a complete BDE less DAO solution then ?

www.gm-software.de

Other Threads