xml c#-4.0 xml-parsing strongly-typed-dataset

DataSet.DataTable.DataRow(Single) a XML String



c#-4.0 xml-parsing (2)

¿Qué es específicamente el error que está recibiendo o qué está fallando? Desde el código, parece que debe tener una versión XML de una DataTable con una fila.

Tengo datasets fuertemente tipados en el proyecto en el que estoy trabajando actualmente y necesito convertir un objeto DataRow del DataSet (solo 1 DataTable en el DataSet) en una cadena XML. Intenté lo siguiente con una falla total:

string originalXmlString = string.Empty; DataSet ds = new DataSet(); ds.Tables.Add(this.ObjectDataRow.Table); ds.Tables[0].ImportRow(this.ObjectDataRow); using (StringWriter sw = new StringWriter()) { ds.Tables[0].WriteXml(sw); originalXmlString = sw.ToString(); } req.OriginalDataRow = originalXmlString;

¡Cualquier ayuda sería muy apreciada!

Gracias, Keith


Pude averiguarlo con la ayuda de una página de MSDN con respecto a la función Clonar () .

El siguiente código está revisado y funciona muy bien:

string originalXmlString = string.Empty; DataSet ds = new DataSet(); //ds.Tables.Add(this.ObjectDataRow.Table); ds.Tables.Add(this.ObjectDataRow.Table.Clone()); ds.Tables[0].ImportRow(this.ObjectDataRow); using (StringWriter sw = new StringWriter()) { ds.Tables[0].WriteXml(sw); originalXmlString = sw.ToString(); } req.OriginalDataRow = originalXmlString;