DataTable.Clear doesn't get rid of indices?

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top