Board index » delphi » Number out of range error on Pdox table create w/autoinc primary key

Number out of range error on Pdox table create w/autoinc primary key

Hi Guys,

I'm getting the following error when trying to create a Paradox table
with an auto increment field as the primary key.

Project TableCreate.exe raised exception class EDBEngineError
with message 'Number is out of range.
Table does not exist.
Table: <filespec>'.  Process stopped.
Use Step or Run to continue.

I'm using Delphi 4 and don't know whether I'm doing something wrong or
it's a bug in D4.  Here's a code snippet.

{ *****************************************************
  Create phones table

Quote
}

procedure TfrmMain.CreatePhones(lAsk : Boolean);
Begin
     with tblCreate do
     Begin
          Active := False;
          DatabaseName := sDataPath;
          TableType    := ttParadox;
          TableName    := 'Phones.db';

          if (lAsk) and (Exists) and (MessageDlg(
                'The ' + TableName + ' table already exists.' +
                #13 + #10 +
                #13 + #10 +
                'Do you want to overwrite the existing table?',
                mtWarning,
                [mbYes, mbNo], 0) = mrNo) then
                Exit;

          if Exists then
             DeleteTable;

          with FieldDefs do
          Begin
               Clear;
               // TableKey = TableID, Accountno, StudentNo
               Add('TableKey',   ftString,  10, True);
               Add('PhoneID',    ftAutoInc, 00, True);
               Add('PhoneType',  ftString,  08, True);
               Add('PhoneNo',    ftString,  14, True);
               Add('PhoneExt',   ftString,  05, False);
          end;

          with IndexDefs do
          Begin
               Clear;
               Add('', 'PhoneID', [ixPrimary, ixUnique]);
               Add('PhoneType', 'TableKey; PhoneType',
[ixCaseInsensitive]);
          End;

          CreateTable;
     End;
end;

What am I doing wrong?

Thanks for any help,
Steve Harp
sgh...@mindspring.com

 

Re:Number out of range error on Pdox table create w/autoinc primary key


In a Paradox table the primary key can only consist of the first N fields in
the table. You are trying to use the second field as the primary key. Also,
omit the ixUnique for the primary key.  The primary key is unique by
definition.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads