首页  编辑  

Table的ADD方法的一个问题

Tags: /超级猛料/Database.数据库相关/安装、杂项和其他/   Date Created:

Q:  I use the help file example for the ADD method and I get an error message "comma expected".  Why?

A:  The ADD method requires an undocumented fourth parameter.  (OOPS!)  It says whether the field is required.  (true = required)

Here is the working code for that example:

var

 t: tTable;

begin

t := tTable.create(self);

with t do

 begin

 Active := False;

 DatabaseName := 'lwl';

 TableName := 'hoser';

 TableType := ttParadox;

 with FieldDefs do

   begin

   Clear;

   Add('Field1', ftInteger, 0, false);

   Add('Field2', ftInteger, 0, false);

   end;

 with IndexDefs do

   begin

   Clear;

   Add('Field1Index', 'Field1', [ixPrimary, ixUnique]);

   end;

 CreateTable;

 end;

end;