By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,150 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,150 IT Pros & Developers. It's quick & easy.

Issue passing DataSet as XML from WebService

P: n/a
Hello,
I have a WebService that sends a client a DataSet as XML (I use a
DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter
in the WebService. The client coverts the XML Back to a DataSet (using
StringReader sr = new StringReader(xml); DataSet ds = new DataSet();
ds.ReadXml(sr)).
The client then makes changes to this DataSet, and sends the dirty dataset
back to the WebService using another GetXml on 'ds'.

The WebService re-converts the xml into a DataSet (using a DataSet ds = new
DataSet(); ds.ReadXml; )and executes a DataAdapter.Update(ds).

The problem is, all the rows in the dirty dataset passed back from the
client get appended to the DataBase with new primary keys (the primary key
field is autogenerated in the database) (instead of only the dirty rows
getting updated.) Am I doing something wrong?

Please help.

Best,
Andy

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Do something like this:
DataSet ds = new DataSet();
ds.ReadXml("datafromserver.xml");
ds.AcceptChanges(); // accept all this data

// then make your edits, and write out just the new stufff:

DataSet diff = ds.GetChanges();
diff.WriteXml(@"..\..\diff.xml", XmlWriteMode.DiffGram);

// and send that back to the server

On the server you can merge the changes in using the Merge method.
"Andy" <av*****@e-470.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,
I have a WebService that sends a client a DataSet as XML (I use a
DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter
in the WebService. The client coverts the XML Back to a DataSet (using
StringReader sr = new StringReader(xml); DataSet ds = new DataSet();
ds.ReadXml(sr)).
The client then makes changes to this DataSet, and sends the dirty dataset
back to the WebService using another GetXml on 'ds'.

The WebService re-converts the xml into a DataSet (using a DataSet ds = new DataSet(); ds.ReadXml; )and executes a DataAdapter.Update(ds).

The problem is, all the rows in the dirty dataset passed back from the
client get appended to the DataBase with new primary keys (the primary key
field is autogenerated in the database) (instead of only the dirty rows
getting updated.) Am I doing something wrong?

Please help.

Best,
Andy

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.