J
Joe
I can't seem to get this working right...
Here's what I'm doing:
// in the web service
System.IO.StringWriter sw = new System.IO.StringWriter();
// Fill the dataset
....
dataSetMyData.WriteXml(sw, XmlWriteMode.DiffGram);
string s = sw.ToString();
return s;
In the calling app:
// I get the Xml from the service. This works fine.
string dataSetAsString = ws.GetMyData();
System.IO.StringReader xmlString = new
System.IO.StringReader(dataSetAsString);
DataSet ds = new DataSet("Tree data");
ds.ReadXml(new
System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(dataSetAsString
) ) );
ds.ReadXml(xmlString);
// I want to iterate through the dataset and add the items to a treeview
// but there are no items.
foreach (DataTable t in ds.Tables)
{
foreach(DataRow dr in t.Rows)
treeView1.Nodes.Add(dr.ItemArray.ToString() );
}
I also tried to do a ds.WriteXml("C:\\Temp\\MyXml.xml"); but it doesn't
contain any records.
Is there something I'm not doing to poplate the DataSet?
Here's what I'm doing:
// in the web service
System.IO.StringWriter sw = new System.IO.StringWriter();
// Fill the dataset
....
dataSetMyData.WriteXml(sw, XmlWriteMode.DiffGram);
string s = sw.ToString();
return s;
In the calling app:
// I get the Xml from the service. This works fine.
string dataSetAsString = ws.GetMyData();
System.IO.StringReader xmlString = new
System.IO.StringReader(dataSetAsString);
DataSet ds = new DataSet("Tree data");
ds.ReadXml(new
System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(dataSetAsString
) ) );
ds.ReadXml(xmlString);
// I want to iterate through the dataset and add the items to a treeview
// but there are no items.
foreach (DataTable t in ds.Tables)
{
foreach(DataRow dr in t.Rows)
treeView1.Nodes.Add(dr.ItemArray.ToString() );
}
I also tried to do a ds.WriteXml("C:\\Temp\\MyXml.xml"); but it doesn't
contain any records.
Is there something I'm not doing to poplate the DataSet?