DataTable.Clear doesn't get rid of indices?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to dynamically change a DataTable by clearing the table, columns, rows, and PrimaryKey -- recreating the column collection, recreating the PrimaryKey, and finally adding the new rows

However, after invoking DataTable.Clear() along with clearing all the other information, the table still has all the old indices defined. If my new column collection has, for example, one less column than before, the table still has an index that refers to the now non-existant column and when I add new rows to the table I get an exception when trying to maintain that index

How can I clear all the indices for a DataTable at the same time I'm clearing the column collection and rows?? Thanks

-- TB
 
Actually, I think I found it... DataTable.Reset( ) seems to do the trick

-- T

----- TB wrote: ----

I am trying to dynamically change a DataTable by clearing the table, columns, rows, and PrimaryKey -- recreating the column collection, recreating the PrimaryKey, and finally adding the new rows

However, after invoking DataTable.Clear() along with clearing all the other information, the table still has all the old indices defined. If my new column collection has, for example, one less column than before, the table still has an index that refers to the now non-existant column and when I add new rows to the table I get an exception when trying to maintain that index

How can I clear all the indices for a DataTable at the same time I'm clearing the column collection and rows?? Thanks

-- TB
 
Back
Top