trying to use diffgram to update database

Hi there.

Im trying to use a diffgram xml message to update the northwind database in sql server.

the code im using executes but the changes are not updated. The code im using is from a text book. The code is supposed to change the contact name from Maria Anders to Maria in the customers table. I've added a reference to the SQLXML .NET assembly

This is the xml fiile: diffgram.xml

<?xml version="1.0" standalone="yes"?>




Maria Anders

visual studio has underlined "Customer1" and the tooltiptext states that another object on this page is already using the ID "Customer1" How ever this is how the xml is presented in the book. Im sure this is why the update is not working but im not entirely sure. any help would be much appreciated.

This is the c# code:

using Microsoft.Data.SqlXml;

using System.IO;

private void btnUpdate_Click(object sender, System.EventArgs e)


SqlXmlCommand sxc = new SqlXmlCommand(@data source=(local)HOME; +

"database=Northwind;" + "Integrated Security=SSPI");

// Set up the DiffGram

sxc.CommandType = SqlXmlCommandType.DiffGram;

sxc.SchemaPath = @....diffgram.xsd;

FileStream fs = new FileStream(@....diffgram.xml, FileMode.Open);

sxc.CommandStream = fs;



// And execute it


label1.Text = "Database was updated";


catch (SqlXmlException ex)


ex.ErrorStream.Position = 0;

string strErr = (new StreamReader(ex.ErrorStream).ReadToEnd());

label2.Text = strErr;


catch (Exception ex)


label3.Text = ex.Message;







and this is the schema:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!