Thanks, C. I appreciate the response. I did try something like you initially 
suggested and it did "cause grief." The rest of your suggestion is 
interesting. I'm saving your message but, ultimately, I think I'm going to 
take the easy way out -- it's time to move on. I'm just going to create a 
DataSet with 100 string fields and make one visible each time a user needs 
to "add" a new field. I'll write separate routines for the few fields that 
won't be strings. A hundred or even a thousand blank fields only adds a 
couple K to a file, so the overhead is pretty minimal--even though it sort 
of goes against my mindset, I guess it's time for me to recognize that 
memory is plentiful and we're not working in MS-DOS anymore :-)

It's a little like thinking about using a dynamic array but deciding to used 
a fixed array, isn't it?

Thanks again -- Al


----- Original Message ----- 
From: "CM" <[EMAIL PROTECTED]>
To: "Moderated discussion list about database programming with Borland's 
Delphi" <[email protected]>
Sent: Thursday, July 12, 2007 11:34 AM
Subject: Re: Adding Fields to ClientDataSets


|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 -
|

_______________________________________________
Delphi-DB mailing list
[email protected]
http://www.elists.org/mailman/listinfo/delphi-db

Reply via email to