How to add a field programatically to a TAdoTable in Delphi

后端 未结 6 731
无人及你
无人及你 2021-01-16 10:48

In my Delphi 2009 application I need to check if a field exists and if it doesn\'t add it during application execution.

I have figured out the test for the field,

6条回答
  •  执笔经年
    2021-01-16 11:28

    Greate function works well!! just the part

         for i := 0 to FieldsList.Count - 1 do
         begin
            FieldDef := DataSet.FieldDefList.FieldByName(FieldName);
            Field := FieldDef.CreateField(DataSet.Owner, nil, FieldName, False);
            try
               Field.name := FieldName + IntToStr(random(MaxInt)); // make the name unique
            except
               Field.Free;
               raise ;
            end;
         end;
    

    replace FieldName by FieldsList[i]

提交回复
热议问题