locked
DataTable WriteXml

    Question


  • Hello,

     Hello;

     
    I am trying to store the contents of a table in a file, the problem is that xml is giving me the following error, the issue is that I can store the result of the table in a text file.
     
    Cannot serialize the DataTable. DataTable name is not set

     

    StreamWriter xmlDoc = new StreamWriter("C:\\resultados.xml");

    Res.WriteXml(xmlDoc);

    xmlDoc.Close();

    Tuesday, May 12, 2009 10:39 AM

Answers

  • Hi,

    Before serializing you set some name to a table like...

    objDTComments.TableName = "TableName";
    objDTComments.WriteXml(@"F:\Mydata.xml");

    Where objDTComments is a DataTable

     
    Thanks AnupDG
    Tuesday, May 12, 2009 10:59 AM

All replies

  • Hi,

    Before serializing you set some name to a table like...

    objDTComments.TableName = "TableName";
    objDTComments.WriteXml(@"F:\Mydata.xml");

    Where objDTComments is a DataTable

     
    Thanks AnupDG
    Tuesday, May 12, 2009 10:59 AM
  • Thanks AnupDG this solve my problem
    Tuesday, June 19, 2012 3:41 PM