N
nvx
Hello.
I experience a problem with columns in a DataSet. I need to add,
remove, and rename columns in one table. I'd like to avoid changing
the columns, but unfortunately I can't.
The table is bound to a DataGridView. Adding and removing columns is
not a problem, this works perfectly. The problem is what to do when I
need to rename a column. I tried to rename the column in the DataTable
and change the DataPropertyName property of the corresponding
DataGridViewColumn. Everything seems to work fine. Then I want to save
the DataSet to a .mdb file, so I do the following:
1. remove the column that was renamed,
2. add a new one with the correct name,
3. mark all unchanged rows in the DataTable as modified,
4. rebuild the insert, delete, and update commands using the
CommandBuilder, and
5. call TableAdapter.Update(...);
This routine works perfectly if I add some new columns and/or remove a
few of them only. If I try to use this with a renamed column that was
already present in the DataSet, it fails. Although it does not throw
an exception, the saved file contains blank fields instead of the
values in the renamed column.
It confuses me a lot. What should I do to make this work?
Any help would be much appreciated.
Best regards,
nvx
I experience a problem with columns in a DataSet. I need to add,
remove, and rename columns in one table. I'd like to avoid changing
the columns, but unfortunately I can't.
The table is bound to a DataGridView. Adding and removing columns is
not a problem, this works perfectly. The problem is what to do when I
need to rename a column. I tried to rename the column in the DataTable
and change the DataPropertyName property of the corresponding
DataGridViewColumn. Everything seems to work fine. Then I want to save
the DataSet to a .mdb file, so I do the following:
1. remove the column that was renamed,
2. add a new one with the correct name,
3. mark all unchanged rows in the DataTable as modified,
4. rebuild the insert, delete, and update commands using the
CommandBuilder, and
5. call TableAdapter.Update(...);
This routine works perfectly if I add some new columns and/or remove a
few of them only. If I try to use this with a renamed column that was
already present in the DataSet, it fails. Although it does not throw
an exception, the saved file contains blank fields instead of the
values in the renamed column.
It confuses me a lot. What should I do to make this work?
Any help would be much appreciated.
Best regards,
nvx