
Adding fields to existing ADO tables
Quote:
> I've been trying to dynamically add fields to an existing Access
> database/table using ADO and Microsoft Jet as my provider, without
> success. The table already contains some fields, and I desperately need
> the ability to add more based on user input. Can anyone give me a hand
> with this one?
Well, you can use an ALTER TABLE statement(SQL), but I would not recommend it.
If you don't mind my saying so(I'm glad you don't *grin*) any time I get the
urge to dynamically create new fields in a table, I examine my data model VERY
carefully. Usually, if I'm wanting to add new fields to an existing table on
the fly, something is not right in my data model. Get a book on database design
before you proceed and read the chapters on normalization of data.
IE: instead of having a table looking like this:
TABLE CUSTOMER
Firstname
Lastname
Street
City
Zip
and I want to add a field Phone Number, I would instead break it into 3 tables:
TABLE CUSTOMER
customerID
TABLE INFO_TYPE
infotypeID
infotype_description
TABLE CUSTOMER_INFO
customerID
infotypeID
value
This format allows me to add unlimited information types and unlimited
information about the customers, without modification to the underlying database
structure.
Just a thought.
--
----------------------------------------------------------------------------
| Jeff Goslin - Monument | "Oh Bentson, you are so |
| | ravages of intellect." |
| http://www.acs.oakland.edu/~jggoslin | --Evil, The Time Bandits |
----------------------------------------------------------------------------
| how come everyone elses religion is a cult but your cult is a religion |
----------------------------------------------------------------------------