Board index » delphi » How to create an AutoIncrement Field from Delphi

How to create an AutoIncrement Field from Delphi

I would like to create an autoincrement field in a Paradox table, not
using Database desktop or Paradox, but from my Delphi EXE file.
However, Delphi does not allow to use physical field types (which an
AutoIncrement field is), but only logical field types. These logical
field types do not provide for the AutoIncrement field type.

Any suggestions ?

--------------------------------------
Rik Gruwez
gru...@unicall.be
http://uc2.unicall.be

"There is no substitute for cubes"

 

Re:How to create an AutoIncrement Field from Delphi


Solution :

1. Use TQuery
2. TQuery.SQL :

   CREATE TABLE "DEMOTBL.DB"
   (
   RecNr AUTOINC,           <- Bingo !    
   Firma CHAR(20),
   Vorname CHAR(15),
   Nachname CHAR(25),
   PRIMARY KEY(RecNr)
   )                              

3. TQuery.ExecSQL

procedure TMainForm.BtnCreateClick(Sender: TObject);
begin
  try
    QueryCreate.ExecSQL;
    BtnCreate.Caption := 'Table created!'
  except
    BtnCreate.Caption := 'Error!';
    raise
  end
end;

Regards

Andy

Other Threads