TClientDataSet[25]: 自动增长字段(ftAutoInc) 与字段默认值
作者:互联网
自动增长字段:
//建立方法一: 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;
标签:25,begin,end,do,Create,ClientDataSet1,DataSet,TClientDataSet,默认值 来源: https://www.cnblogs.com/jijm123/p/13976676.html