自動增長字段:
//建立方法一:
begin
with ClIEntDataSet1 do begin
FIEldDefs.Add('ID', ftAutoInc);
FIEldDefs.Add('Name', ftString, 11);
CreateDataSet;
end;
end;
//建立方法二:
begin
with TAutoIncFIEld.Create(Self) do begin
FIEldName := 'ID';
// AutoGenerateValue := arAutoInc; { 不起作用 }
DataSet := ClIEntDataSet1;
end;
with TStringFIEld.Create(Self) do begin
FIEldName := 'Name';
Size := 11;
DataSet := ClIEntDataSet1;
end;
ClIEntDataSet1.CreateDataSet;
end;
字段默認值:
begin
with TStringFIEld.Create(Self) do begin
FIEldName := 'Name';
Size := 11;
DataSet := ClIEntDataSet1;
end;
with TIntegerFIEld.Create(Self) do begin
FIEldName := 'Age';
DefaultExpression := '18';
DataSet := ClIEntDataSet1;
end;
ClIEntDataSet1.CreateDataSet;
end;