Board index » delphi » Paradox Tables - Key Fields

Paradox Tables - Key Fields

I recently had to make an application that needed to dynamically
create tables.  This worked fine until i add another key field and
tried to use the Add method with the IndexDefs object. The code is as
follows.

    with Table1.IndexDefs do
    begin
        Clear;
        Add('TITLE', 'TITLE', [ixPrimary,ixUnique]);
        Add('UNIQUECODE', 'UNIQUECODE', [ixPrimary,ixUnique]);
    end;

With just ONE field specified as ixPrimary, it works fine (and i'm
assuming ixPrimary means a key field). Can anyone help?

Thanks in advance,
Scott

 

Re:Paradox Tables - Key Fields


Quote
d...@ecn.net.au (Scott Maskiel) wrote:
>I recently had to make an application that needed to dynamically
>create tables.  This worked fine until i add another key field and
>tried to use the Add method with the IndexDefs object. The code is as
>follows.
>    with Table1.IndexDefs do
>    begin
>        Clear;
>        Add('TITLE', 'TITLE', [ixPrimary,ixUnique]);
>        Add('UNIQUECODE', 'UNIQUECODE', [ixPrimary,ixUnique]);
>    end;
>With just ONE field specified as ixPrimary, it works fine (and i'm
>assuming ixPrimary means a key field). Can anyone help?

Scott,
Here's my method for creating a Table with multiple key fields.  The
following creates a composite key consisting of 4 fields.

       with IndexDefs do
       begin
           Clear;
           Add('POIndex','Customer Number;PO Number;Form Number;Ship
Code;',  [ixPrimary,ixUnique]);
       end;
       CreateTable;

Re:Paradox Tables - Key Fields


Quote
bviv...@primenet.com (Brian Vivian) wrote:
>Scott,
>Here's my method for creating a Table with multiple key fields.  The
>following creates a composite key consisting of 4 fields.
>       with IndexDefs do
>       begin
>           Clear;
>           Add('POIndex','Customer Number;PO Number;Form Number;Ship
>Code;',  [ixPrimary,ixUnique]);
>       end;
>       CreateTable;

I run into the similar situation as Scott, but the Paradox table I
need  have two secondary index ( and no primary key),
and the value in those index can be the same (duplicate).

I use my every effort to try out almost every combination of the Add
syntax, but all fail. I wonder : Did Paradox table  support these kind
of index? (I mean no primary key, two duplicate secondary index)

Belows is my code:
      tblParadox.IndexDefs.Add('FirstName', 'My First Name' , []);
      tblParadox.IndexDefs.Add(''LastName', 'My Last Name', []);
      tblParadox.CreateTable;
      Result : run time error.

      tblParadox.IndexDefs.Add('FirstName', 'My First Name' ,
[ixNonMaintained]);
      tblParadox.IndexDefs.Add(''LastName', 'My Last Name',
[ixNonMaintained]);
      tblParadox.CreateTable;
      Result: Compilatin error, ixNonMaintained is a 'Unknown
Identifier'
      I think ixPrimary means Primary key, but in my case, this
Paradox have no Primary key, but I still try:

     tblParadox.IndexDefs.Add('FirstName', 'My First Name' ,
[ixPrimary, ixUnique);
      tblParadox.IndexDefs.Add(''LastName', 'My Last Name', []);
      tblParadox.CreateTable;
      Result: Run time error.
 .........
.........
  All fail,
      Could anybody help me?
      thanks.    

Email: zli...@iiidns.iii.org.tw
or Email: mail.adc.iii.org.tw

Other Threads