Mike, Are you sure about that? Reading the help for update sounds like it looks at the fields and updates the definitions according to the fields, not the fields according to the definitions. I'll try it anyway though.
I have tried just creating a new TField Object and adding it to the ClientDataSet using the Fields.Add method, but when trying to add a value to the field it couldn't find it. I'm not sure why. Sincerely, Brad Gies ------------------------------------- NLM Software Southfield, MI, USA ------------------------------------- > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:delphi-talk- > [EMAIL PROTECTED] On Behalf Of M Tuttle (KS) > Sent: Monday, October 10, 2005 7:58 PM > To: Delphi-Talk Discussion List > Subject: Re: Adding a field to a ClientDataSet at runtime > > Something like this. Do you also need to add these field to a query? > > Procedure SomeProcedure > var > fldStringField: TStringField; > fldIntegerField: TIntegerField; > begin > > with cdsAddress do > begin > //* Add the persistent field > with FieldDefs do > begin > fldIntegerField := TIntegerField.Create(cdsAddress); > with fldIntegerField do > begin > FieldName := 'FIELD_NAME'; > DisplayLabel := FieldName; > DataSet := cdsAddress; > Name := cdsAddress.Name + FieldName; > cdsAddress.FieldDefs.Add(fldIntegerField.Name, > ftInteger, > 0, False); > end; > > fldStringField := TStringField.Create(cdsAddress); > with fldStringField do > begin > FieldName := 'ANOTHER_FIELD_NAME'; > DisplayLabel := FieldName; > DataSet := cdsAddress; > Name := cdsAddress.Name + FieldName; > cdsAddress.FieldDefs.Add(fldStringField.Name, ftString, > 1, > False); > end; > > //* Update the field defs > Update; > end; > end; > end: > > ----- Original Message ----- > From: "Gies,Brad" <[EMAIL PROTECTED]> > To: "Delphi-Talk Discussion List" <[email protected]> > Sent: Monday, October 10, 2005 6:44 PM > Subject: Adding a field to a ClientDataSet at runtime > > > > > > Does anyone know how to add a new field to a ClientDataSet after the > > DataSet is already created? Is it possible? > > > > Sincerely, > > > > Brad Gies > > ------------------------------------- > > NLM Software > > Southfield, MI, USA > > ------------------------------------- > > > > > > > > > > > > > > > > This e-mail is intended only for the person or entity to which it is > addressed and may > > contain confidential and/or privileged material. Any review, > retransmission, > > dissemination or other use of, or taking of any action in reliance upon, > this information > > by persons or entities other than the intended recipient is prohibited. > If you > > received this message in error, please contact the sender immediately > and > delete > > the material from your computer. > > __________________________________________________ > > Delphi-Talk mailing list -> [email protected] > > http://www.elists.org/mailman/listinfo/delphi-talk > > > > > > > __________________________________________________ > Delphi-Talk mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi-talk This e-mail is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this message in error, please contact the sender immediately and delete the material from your computer. __________________________________________________ Delphi-Talk mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi-talk
