An XML format can also be used to identify the current and original data values (data elements) along with row error information and row order. This is referred to as the DiffGram XML format. The DiffGram XML format is what is usually used in the .NET Framework to send and receive information by the applications. It is what is serialized for transport across a network connection to other applications or services and is the persistent DataSet representation. You load up the contents of the DataSet from XML with the ReadXml method and write the contents of this DataSet to XML using the WriteXml method. One of the options you have is to specify that the contents be read or written in a DiffGram XML format. This is mentioned here because you can use the DiffGram XML format to update data in tables in a Microsoft SQL Server 2000 database environment. Also, the DiffGram format is pretty much already set up to handle your optimistic concurrency needs.
Basically, a DiffGram is divided into three sections (blocks). The first one contains the current data (the current DataSet values block), the second is the original data block ( < diffgr :before> the data as it was read in from the data source before it was modified), and the third is the error block ( <diffgr:errors> ) for noting whether any errors (such as optimistic concurrency) have occurred as you processed (updated) the data.
As you can see from the following DiffGram example, the data row with DiffGram ID of "Customers1" has been modified ( diffgr:hasChanges="modified" ), and there is a corresponding <diffgr:before> entry that contains the original values as they were read from the database. These will be used in checking for optimistic concurrency violations.
In addition, the data row DiffGram ID of "Customers2" shows that an error was encountered when it was updated ( diffgr:hasErrors="true" ). Also, there is a corresponding entry in the diffgr:errors block that shows that the error is an "Optimistic Concurrency Violation."
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"> <CustomerDataSet> <Customers diffgr:id="Customers1" msdata:rowOrder="0" diffgr: hasChanges="modified" > <CustomerID>ABC </CustomerID> <ContactName>Peter Johnson</ContactName> </Customers> <Customers diffgr:id="Customers2" msdata:rowOrder="1" diffgr: hasErrors="true"> <CustomerID>ALFKI</CustomerID> <ContactName>Maria Anders</ContactName> </Customers> <diffgr:before> <Customers diffgr:id="Customers1" msdata:rowOrder="0"> <CustomerID>ABC </CustomerID> <ContactName>Peach</ContactName> </Customers> </diffgr:before> <diffgr:errors> <Customers diffgr:id="Customers2" diffgr:Error="Optimistic Concurrency Violation."/> </diffgr:errors> </CustomerDataSet> </diffgr:diffgram>