Board index » delphi » Adding Fields to Table created during runtime

Adding Fields to Table created during runtime

I have an adodataset that I'm creating at runtime with adodataset1:=
tadodataset.create(self);  I set the connection, commandtext, datasource,
masterfields, etc.  I defined the datasets as being cached updates.

I want to create persistent fields in this tadodataset at runtime.  I know
how to use the field editor at design time, but what can be done during the
run time?  I've tried using a variable defined as tcurrencyfield type and
the create method.  Then I set what I thought were the required properties
to bind the field to the dataset.  I'm having limited success.  The
appearance in my dbgrid is fine, but there's a strange problem when saving
the record.

Will someone show me how I can add a persistent currencyfield to my dataset,
please?

Debbie Erickson

 

Re:Adding Fields to Table created during runtime


Quote

>I want to create persistent fields in this tadodataset at runtime.  I know
>how to use the field editor at design time, but what can be done during the
>run time?  

var
  f : TField;
  i : integer;
begin
 tAdoDataset1.FieldDefs.Update
  tAdoDataset1.Close;
  for i := 0 to  tAdoDataset1.FieldDefs.Count - 1 do
   //create persistent field that do not exist
   if  tAdoDataset1.FindField(table1.FieldDefs[i].Name) = nil then
       tAdoDataset1.FieldDefs.Items[i].CreateField( tAdoDataset1);
end;
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads