Post by Fred S. LindowI need to add a field to an existing ADOTable during run-time.
Pulled out every Delphi book I got in the office and no luck. Could
not find anything in the newsgroups either.
Best Regards,
Fred
without knowing which kind of field you want here you have an example
for a look-up one.
with ADOContacto do
begin
Close;
CommandText := 'whatever';
CommandType := cmdText;
FieldDefs.Update;
for i:= 0 to FieldDefs.Count - 1 do
if FindField(FieldDefs[i].Name) = nil then
FieldDefs.Items[i].CreateField(ADOMyTable);
F := TStringField.Create(ADOMyTable);
F.FieldName := 'myField';
F.DisplayLabel := 'myFieldLabel';
F.name := 'ADOmyNewField';
F.FieldKind := fkLookup;
F.DataSet := ADOMyTable;
F.KeyFields := 'myKeyField';
F.Size := 30;
F.LookupDataSet := ADOLookUpTable;
F.LookupKeyFields := 'myLookUpFields';
F.LookupResultField := 'myResultField';
Fields.Add(F);
open;
end;
plus i would suggest to avoid ADOTable and use only ADOQuery or
ADODataset for operations which produce result sets.
Good luck
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam