Re: Add field to ADOTable and a Column for a tDbGrid at runtime
- From: danielk1@xxxxxxxxx
- Date: 20 Oct 2006 14:43:52 -0700
Is your DBGrid Datasource pointing to the TADOTable and the TADOTable
pointing to the connection? Also is the DBGrid.Active = True?
If all this is setup, and you refresh the DBGrid, the grid will
repopulate with the new column. However, if you have columns coded or
in the control, this may be a problem.
Pablo Romero wrote:
Hi Fellas:
I have a little problem.
I need to add a field to a MS SQL Table at run-rime.
I did
ADOtable.close;
ADOCommand.CommandText := 'ALTER TABLE Empleados ADD COLUMN Notas
TEXT(25)';
ADOCommand.Execute;
ADOTable.Open;
Ok, the field is added.
Now i want to use that field in my program. So I Did:
with ADOTable do
begin
Close;
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.DataSet := ADOMyTable;
F.Size := 30;
Fields.Add(F);
open;
end;
Ok, the field is created.
Now I want to add this field to a column for a TDbgrid that is shown at this
time
The grid is showing the 3 fields that my ADOTABLE has. I added a 4th.
When I add the field to the Dbgrid using the 'tcolumn' object and the 'add'
method, the grid changes and shows one column, the lastest, the new.
Any ideas, please?
Regards.
Pablo Romero
.
- References:
- Add field to ADOTable and a Column for a tDbGrid at runtime
- From: Pablo Romero
- Add field to ADOTable and a Column for a tDbGrid at runtime
- Prev by Date: Re: TADODataset.Filter?
- Next by Date: Re: Saving Image/Picture to Database using ADO
- Previous by thread: Add field to ADOTable and a Column for a tDbGrid at runtime
- Next by thread: Re: Add field to ADOTable and a Column for a tDbGrid at runtime
- Index(es):
Relevant Pages
|