none
Optimistic Concurrency RRS feed

  • Question

  • Hello everyone,
    My question is regarding ADO.NET 2.0 and optimistic concurrency. 

    Normally, If I create a dataset in my project, go to the server explorer and drag and drop at table in the dataset designer, a table adapter is created. If the table I'm dealing with has a timestamp field, the update command gets generated with a 'WHERE ... timestamp = Original_timestamp' clause. This implements optimistic concurrency and is the behaviour I desire.

    Now, for some reason, if my project is a mobile project (one that uses the .NET compact framework), this behaviour does not occur. Tables added to the designer that contain a timestamp field do not get created with an update command that contains the 'WHERE ... timestamp = Original_timestamp' clause.  I can easily add this manually, however (not surprisingly), if I do anything that regenerates the db commands (i.e. configure the table), this clause is removed.

    Anyone have any suggestions?

    Thanks,
    Jordan
    Thursday, May 21, 2009 3:14 PM

All replies

  • Can you write the complete code?
    In this concurrency. only to check last timestamp value is same or not before doing changes.


    PK
    Saturday, May 23, 2009 9:53 PM
  • Hi Jordan,

    I'm not quite clear why, but optimistic concurrency is disabled when connecting to SQL Server on .Net compact framework. You could right-click the table or tableadapter, choose "Configure..", then click "Advanced Options...", and you will see the "Use optimistic concurrency" checkbox is disabled.

    Another evidence is that, the code generated on .Net compact framework use System.Data.DbType (instead of System.Data.SqlDbType) as command parameter types, which does not define Timestamp type at all.
    Wednesday, June 3, 2009 2:13 AM