Paradox primary indexes

I want to create a paradox table at run time and I want to set a primary key for first two fields an error occured while I attempt to do that, this is the function wich produce an error:

function CreateTrafficTable: Boolean;
var
  NewTable: TTable;
begin
  Result:= False;
  NewTable := TTable.Create(nil); // Create table object
  with  NewTable  do
  begin
    Active := False;
    TableName := ExtractFilePath(ParamStr(0)) + 'Traffic.db';
    TableType := ttDefault; // Paradox
    FieldDefs.Clear;

    (*** Create fields  ***)
    FieldDefs.Add('Date of Issue', ftDateTime, 0, True);
    FieldDefs.Add('Record Period From', ftTime, 0, True);
    FieldDefs.Add('Record Period To', ftTime, 0, True);
    FieldDefs.Add('Result List', ftString, 10, True);
    FieldDefs.Add('TrunkGroupList', ftString, 40, True);
    FieldDefs.Add('Avle', ftInteger, 0, True);
    FieldDefs.Add('Seiz', ftInteger, 0, True);
    FieldDefs.Add('Answ', ftInteger, 0, True);
    FieldDefs.Add('Occ', ftFloat, 0, True);
    FieldDefs.Add('Conv Occ', ftFloat, 0, True);
    FieldDefs.Add('Thrsw', ftInteger, 0, True);
    FieldDefs.Add('Call Att', ftInteger, 0, True);
    FieldDefs.Add('Cong', ftInteger, 0, True);
    FieldDefs.Add('Offd Atg', ftInteger, 0, True);

    (*** Create primary key ***)
    IndexDefs.Clear;
    IndexDefs.Add('ix1', 'Date Of Issue', []);
    IndexDefs.Add('idx2', 'Record Period From', []);

    (*** Create physical table ***)
    CreateTable;
    Result:= True;

  end ; // With NewTable


Thanks for advance,
Motaz
LVL 7
MotazAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
this q is posted twice, delete this
0
ahalyaCommented:
If i recall right you should use

IndexDefs.Add('ix1', 'Date Of Issue', [ixprimary]);
0
PhrAtoRCommented:
there can only be ONE primary key in a table!!
try this
with IndexDefs do begin
               Clear;
               // first key has no name, because it's the primary
               Add('', 'COF', [ixPrimary, ixUnique]);
Add('key1,'DFE',[ixunique])
          end;

hope this will help
-PhrAtoR
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.