I have a DataSet that can be updated when someone updates a DataGrid. After the update, I want to Merge the changes from the DataGrid's DataSet to another DataSet. Here is some sample code:
DataSet ds = (DataSet)dataGrid1.DataSou
DataSet dsClone = ds.Copy();
DataRow dr = ds.Tables.Rows[dataGrid
dr["subject"] = "hello";
DataSet changes = ds.GetChanges();
if (changes != null)
dsClone.Merge(changes, false, MissingSchemaAction.Error)
After this code is executed, I end up with an extra row in the cloned DataSet and the row does not get updated. The DataSet was created from an XML file shown below. I did a DataSet.ReadXML and then the DataGrid's DataSource member was set to the DataSet. The XML has a primary key (msgId).
<?xml version="1.0" standalone="yes"?>
<msgText versionNo ="1.0">disk is full</msgText>
<subject>some other subject</subject>
<msgText versionNo="1.0">The message goes here</msgText>
How can I get the DataSet to UPDATE the row as opposed to adding a brand new row when I call Merge?