Reputation: 5640
I have a Delphi 2007 app that interacts with an Access 2000 database. I have made changes to the database structure (addition of fields) and need to make them visible in the Delphi application but that is proving difficult. I made a minimal Delphi application and Access database and the same issue is seen there.
My steps were:
TDBGrid
to the formTDataSource
onto the formDatasource
property of the grid to DataSource1
TTable
to the formDataset
property of the TDataSource
to Table1
DataBaseName
property of Table1
to the alias name created for the database.TableName
property to the name of the table in your original Access database.Active
property of the Table to TRUE. All the fields originally defined in the database appear in the grid.
The problem is when I want to add fields later to this. I can make them appear as columns in the grid by rebuilding the whole thing from scratch, but there must be an easier way!What is accepted best practice for forcing database structure changes through to the Delphi IDE and resulting application?
** Answer to Ken White's comment **
Thanks Ken. I appreciate the reasons for the Columns
property of the DBGrid
when you may not want all the fields in your grid - my issue is that when I use MS Access to add some fields to the table and then re-open my Delphi project:
TTable
and reconnect it, the FieldDefs
property shows the added fields. All good.Columns
collection is empty.Columns
property and try to add all fields I just get the original fields. If I try to add one field` column, the picklist only gives me the original fields to choose from.I don't understand why the TTable
can see the new fields but the TDatasource
(which has the TTable specified as it's Dataset
property value) cannot.
Upvotes: 0
Views: 195