Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > return Dataset from WebService

Reply
Thread Tools

return Dataset from WebService

 
 
Joe
Guest
Posts: n/a
 
      05-08-2004
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.Defaul t.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?


 
Reply With Quote
 
 
 
 
Manuj Aggarwal
Guest
Posts: n/a
 
      05-08-2004
how about if you just return the DataSet itself without trying to serialize
it yourself.

e.g.

[WebMethod()]
public DataSet GetData()
{
}

ASP.NET will automatically serialize it on the server and if you have .NET
client - it will automatically deserialize the return dataset.

HTH
Manuj Aggarwal

"Joe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Defaul t.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?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return dataset in my webservice with schema casucci@gmail.com ASP .Net Web Services 1 10-07-2008 06:49 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Proper way to return a Dataset to InfoPath from a WebService Mike Morisoli ASP .Net Web Services 2 04-24-2004 01:54 PM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N ASP .Net 1 10-31-2003 02:39 AM
error parsing dataset upon return from webservice Jeff ASP .Net Web Services 0 07-23-2003 01:20 PM



Advertisments