Re: Add field to ADO Table
- From: "Guillem" <guillemvicens-nospam@xxxxxxxxxxxxxxxxxx>
- Date: 19 Jan 2006 06:29:40 -0700
Fred S. Lindow wrote:
> I 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
.
- References:
- Add field to ADO Table
- From: Fred S. Lindow
- Add field to ADO Table
- Prev by Date: Re: Re hlp: Datetime To TTimeStamp!
- Next by Date: Re: How to update/refresh/repaint TDBGrid?
- Previous by thread: Re: Add field to ADO Table
- Next by thread: Re: Add field to ADO Table
- Index(es):
Relevant Pages
|