View Single Post
  #8 (permalink)  
Old 10-13-2007, 01:43 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Cool Re: What is DiffGram?

Updating an existing record by using a DiffGram

In this example, the DiffGram updates customer information (CompanyName and ContactName) for customer ALFKI.

Code:
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql" sql:mapping-schema="DiffGramSchema.xml">
  <diffgr:diffgram 
           xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
           xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    <DataInstance>
      <Customer diffgr:id="Customer1" 
                msdata:rowOrder="0" diffgr:hasChanges="modified" 
                CustomerID="ALFKI">
          <CompanyName>Bottom Dollar Markets</CompanyName>
          <ContactName>Antonio Moreno</ContactName>
      </Customer>
    </DataInstance>

    <diffgr:before>
     <Customer diffgr:id="Customer1" 
               msdata:rowOrder="0" 
               CustomerID="ALFKI">
        <CompanyName>Alfreds Futterkiste</CompanyName>
        <ContactName>Maria Anders</ContactName>
      </Customer>
    </diffgr:before>

  </diffgr:diffgram>
</ROOT>
The <before> block includes a <Customer> element (diffgr:id="Customer1"). The <DataInstance> block includes the corresponding <Customer> element with same id. The <customer> element in the <NewDataSet> also specifies diffgr:hasChanges="modified". This indicates an update operation, and the customer record in the Cust table is updated accordingly. Note that if the diffgr:hasChanges attribute is not specified, the DiffGram processing logic ignores this element and no updates are performed.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Reply With Quote