none
dataset is already associated with an xmldatadocument RRS feed

  • Question

  • I have a method that instantiates an XmlDataDocument passing it a dataset. Second pass at this method throws the following error... dataset is already associated with an xmldatadocument. Does any know why this is happening? The XmlDataDocument should be out of scope and dispose of. Why does the dataset still know about a previous association? How can I disconnect it?

     

    Code Snippet

    foreach (ListViewItem lvi in ListViewColumnOrder.Items)

    {

    XmlNode cdef = CreateColumnDefFromDataViewRow(lvi.DataContext as DataRowView);

    listGroupNode.AppendChild(cdef);

    }

     

     

     

    Code Snippet

    private XmlNode CreateColumnDefFromDataViewRow(DataRowView dr)

    {

    XmlDataDocument dataDoc = new XmlDataDocument(dr.DataView.Table.DataSet);

    }

     

     

     

    Thursday, June 12, 2008 4:24 PM

All replies

  • Since the exception is referring to the DataSet I would suspect that you have to call Dispose on the DataSet. I would give that a try and see if it resolves the issue.
    Friday, June 13, 2008 1:19 PM