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?
 
PhrAtoRConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.