Clearing XML DataSet RRS feed

  • Question

  • Hi guys,

    I'm trying to clear an XML DataSet that was populated as follow but it's not working:

    DataSet ds = new DataSet();
    ds.ReadXml("path to xml", XmlReadMode.InferSchema);


    Here's what MSDN is saying:

    "If the DataSet is bound to an XmlDataDocument, calling DataSet.Clear or DataTable.Clear raises the NotSupportedException. To avoid this situation, traverse each table, removing each row one at a time."


    Does this apply to my case? If so... I've tried the following which is giving me an exception:

    foreach (DataTable dt in ds.Tables) {
                 foreach (DataRow dr in dt.Rows) {

    Please help.
    Sunday, December 2, 2007 7:59 PM


  • That doesn't apply to you, because you're not binding the DataSet to an XmlDataDocument.


    I tested out the code, and it does delete out all rows from all tables. However, the Clear method does not remove the tables themselves. If this is the same behavior you're getting, it is correct. If not, please clarify why it's not working for you.


    Sunday, December 2, 2007 8:26 PM