Revisiting the issue of "Filling the dataset with a table with same name as in another class"

E

Earl

My original post asked the question: what happens when you declare a
datatable with the same name in Class1 as you used in Class2? As Miha
pointed out, "DataSet won't be gc-ed until you drop all references to it ..
while you have at least one living reference DataSet instance will be
there." And Kevin Yu answered that, "If you still hold some reference to the
object, you have to fill the DataTable with other names, because the
original table is still in it." Excellent advice and duly noted.

Here's the issue however. I fill the DS with a dtSupply table in lets say
Class1. I clear this table out of the DataSet in Class2 before filling the
DataSet with a table with the the same dtSupply name as I used in Class1.
The schema for these two tables differs ... but the schema for the Class1
table stays in the DataSet ALSO! So while I can populate a table in Class2
with different data for the same table, the table SCHEMA itself remains in
the DataSet despite being cleared from the DataSet. From a practical
standpoint, this is a non-issue with what I am currently working on, as it
is easy enough to simply use a different name for the tables. But I am
curious if there is a "schema-clear" method for the datatables within the
dataset?
 
K

Kevin Yu [MSFT]

Hi Earl,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that after you have cleared the table, the
schema for the table still remains in the DataSet. If there is any
misunderstanding, please feel free to let me know.

Could you let us know how you cleared the data in the table? Did you use
DataTable.Clear method? As far as I know, the Clear method will not remove
the schema for you but clear data in the table only. So if you need to
remove everything in the table please try to use
DataSet.Tables.Remove("dtSupply") as chen qi recommended.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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