none
DataSet.Merge, Xml, update RRS feed

  • Question

  • Hi.

     

    I am trying to create windows forms clients that update data in near real time on a lan.

     

    I won't go into details but basically i'm trying to get the dataset.merge method to work without creating a concurrency violation. Right now, my smart client apps recieve notification of data update and recieve xml of the update to be merged in their dataset. However, once the dataset merges it always flags a concurrency violation on those rows that were updated.

     

    public void NotifyMeOfUpdate(string xml )

    {

     

    DataSet1 MySet = new DataSet1();

    byte[] byteArray = new byte[xml.Length];

    System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

    byteArray = encoding.GetBytes(xml);

    MemoryStream mXml = new MemoryStream(byteArray);

    MySet.ReadXml(mXml);

     

    this.MyInMemoryDataSet.Merge(MySet, false);

     

    this.MyInMemoryDataSet.AcceptChanges();

     

    }

     

    Now, unfortunately, any row that got merged into MyInMemoryDataSet will cause a concurrency violation. How do I modify or even view the original values the rows compare against when updating using a tableadapter? Any help would be greatly appreciated.

     

     

    EDIT

     

    Here is the even that a client fires when updating its data and sending notification. The previous code snippet is the recieving end.

     

    DataSet1 changes = (DataSet1)MyInMemoryDataSet.GetChanges();

    adapter.Update(changes );

     

    MyInMemoryDataSet.Merge(changes, false);

    Static.RunTime.NotifyServer(changes.GetXml());

     

     

     

     

    Friday, June 15, 2007 7:13 PM

All replies

  • After doing some more research on row versioning, as far as I can tell I shouldn't be getting a concurrency violation.

     

    catch (Exception ex)

    {

    if (ex is System.Data.DBConcurrencyException)

    {

    System.Data.DBConcurrencyException ConException= (System.Data.DBConcurrencyException)ex;

     

    DataRow OriginalValue = ConException.Row[0, DataRowVersion.Original]; //Value is equal to current value in database

     

    DataRow OriginalValue = ConException.Row[1, DataRowVersion.Original];//Value is equal to current value in database

     

    //All values appear to match current values in database... no violation should be thrown.

     

    }

     

    I've got to be overlooking something obviously.

     

    There are null values I'm dealing with, maybe the nulls are not being compared propertly when you use the merge feature? Is there anything else I could be overlooking? I'm using expression columns, but those should be ignored on update.

     

     

    Monday, June 18, 2007 7:51 PM