I could be wrong on this, but I don't think you can add a field to an 
open dataset.  That said, I'm thinking you could use 
dataset.disablecontrols, then close it, then something along the lines 
of dataset.fields.create, save the field, re-enable the controls, and 
the open the dataset again.  You may need to refresh the grid's reading 
the field list again too, but I suspect that may happen on dataset.open.

If loading/saving from file turns out to be required while the dataset 
is "closed" (it's been a while since I've used that), the fields not 
matching up will likely cause grief.  If that turns out to be the case, 
perhaps you could clone the dataset object after saving it to file, THEN 
add the field to the new clone, savetofile as a blank / no-data dataset, 
and have a routine that pipes that data from Dataset1 to Dataset2, with 
appropriate blank/null/default data in whatever "NewField" ends up being.

This is all just wild subjective guessing however. <g>  Just some ideas 
for you to bounce around.  Either way, please do let us know how it 
turns out for you, and what ends up working, K? : )

...btw, this a perfect example of the kind of "magic" users never fully 
appreciate the back-end of.  ; )


- C -




Alan Colburn wrote:
> Hi folks --
>
> Can anyone show me how to add fields at runtime to an open, already existing 
> client data set being stored via the SaveToFile method? I'd like a user to 
> be able to see a DBGrid and, with the click of a menu item, add a new 
> field--without losing anything already in the DB.
>
> Thanks, as always -- Al 
>
> _______________________________________________
> Delphi-DB mailing list
> Delphi-DB@elists.org
> http://www.elists.org/mailman/listinfo/delphi-db
>
>   

_______________________________________________
Delphi-DB mailing list
Delphi-DB@elists.org
http://www.elists.org/mailman/listinfo/delphi-db

Reply via email to