T
Thomas Brown
I need to handle dynamic changes to a table's schema, even when there
is already data present. It appears that the only thing supported by
DataTable is to remove a column so I am pulling all the data out into
a 2D array, performing my manipulations on the raw data, and then
clearing out the table's Rows and Columns collections and attempting
to recreate them. Basically,
Rows.Clear();
Columns.Clear();
RebuildColumns(/*...*/);
RebuildRows(/*...*/);
Where I rebuild the columns from a separate list of schema parameters
that I have available and then rebuild the rows from the 2D array of
raw data that I originally pulled from the table.
For a simple test I am trying to remove the third column from a four
column table (something that I suppose I could have done simply via
Columns.RemoveAt, but am trying this way as a test).
The problem is that when I'm adding the rows back, I'm getting an
exception thrown on adding the second row:
System.IndexOutOfRangeException
"Cannot find Column 3"
System.Data.DataTable.InsertRow
Can anyone shed some light on this for me? Thanks in advance.
-- Thomas Brown
is already data present. It appears that the only thing supported by
DataTable is to remove a column so I am pulling all the data out into
a 2D array, performing my manipulations on the raw data, and then
clearing out the table's Rows and Columns collections and attempting
to recreate them. Basically,
Rows.Clear();
Columns.Clear();
RebuildColumns(/*...*/);
RebuildRows(/*...*/);
Where I rebuild the columns from a separate list of schema parameters
that I have available and then rebuild the rows from the 2D array of
raw data that I originally pulled from the table.
For a simple test I am trying to remove the third column from a four
column table (something that I suppose I could have done simply via
Columns.RemoveAt, but am trying this way as a test).
The problem is that when I'm adding the rows back, I'm getting an
exception thrown on adding the second row:
System.IndexOutOfRangeException
"Cannot find Column 3"
System.Data.DataTable.InsertRow
Can anyone shed some light on this for me? Thanks in advance.
-- Thomas Brown