Concurrency violation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zhuo Li

    Concurrency violation

    Hi, I get this error when I try to save a datatime field to the database
    using OdbcDataAdapter .Update method.
    oAdapter.Update Command.Command Text is like: "update aTable set effetive_from
    =? where primarykey=?"

    The parameter related to this field is like:

    oAdapter.Update Command.Paramte res.Add(new OdbcParameter(" effective_from" ,
    Odbctype.dateti me, 8, "effective_from ");

    The database is Sybase ASA 9.0. The column effective_from' s type is datatime
    in the database.

    Any suggestions/ideas?

    Thanks, Zhuo


  • Ken Foskey

    #2
    Re: Concurrency violation

    On Thu, 18 Sep 2008 09:50:08 -0400, Zhuo Li wrote:
    Hi, I get this error when I try to save a datatime field to the database
    using OdbcDataAdapter .Update method.
    oAdapter.Update Command.Command Text is like: "update aTable set
    effetive_from =? where primarykey=?"
    >
    The parameter related to this field is like:
    >
    oAdapter.Update Command.Paramte res.Add(new
    OdbcParameter(" effective_from" , Odbctype.dateti me, 8, "effective_from ");
    >
    The database is Sybase ASA 9.0. The column effective_from' s type is
    datatime in the database.
    >
    Any suggestions/ideas?
    >
    Thanks, Zhuo
    The simplest way is to disable concurrency checking. In your database
    set up click on the table and then check the settings, advanced from
    memory and remove it. There are multiple descriptions of how to handle
    the problem (generally with autonumber primary keys) but if you are using
    a database exclusively it is not worth the effort

    Ken

    Comment

    • Zhuo Li

      #3
      Re: Concurrency violation

      Thank you for your reply. I think that it is something to do with the
      datetime field and the dataset. When the dataset tries to save a row to the
      database, it compares its "Original data"of the row with what is in the
      database. This comparison always result in difference in the datetime field.
      If there were a simple solution, there would be something in the dataset
      configuration to set the rule of comparing two datetime values only upto
      second. Any idea?

      Thanks,
      Zhuo


      "Zhuo Li" <zli@micros.com wrote in message
      news:e8FG3VZGJH A.212@TK2MSFTNG P06.phx.gbl...
      Hi, I get this error when I try to save a datatime field to the database
      using OdbcDataAdapter .Update method.
      oAdapter.Update Command.Command Text is like: "update aTable set
      effetive_from =? where primarykey=?"
      >
      The parameter related to this field is like:
      >
      oAdapter.Update Command.Paramte res.Add(new OdbcParameter(" effective_from" ,
      Odbctype.dateti me, 8, "effective_from ");
      >
      The database is Sybase ASA 9.0. The column effective_from' s type is
      datatime in the database.
      >
      Any suggestions/ideas?
      >
      Thanks, Zhuo
      >

      Comment

      • Ken Foskey

        #4
        Re: Concurrency violation

        On Fri, 19 Sep 2008 08:09:44 -0400, Zhuo Li wrote:
        Thank you for your reply. I think that it is something to do with the
        datetime field and the dataset. When the dataset tries to save a row to
        the database, it compares its "Original data"of the row with what is in
        the database. This comparison always result in difference in the
        datetime field. If there were a simple solution, there would be
        something in the dataset configuration to set the rule of comparing two
        datetime values only upto second. Any idea?
        I can describe a problem I had and perhaps that will help you.

        DateTimePicker associated with field. Field was sometime null in the
        database. When you picked a new row if (and only if) the field was null
        the control got an is null exception and 'rejected' the change of
        position. I worked around this by disconnecting the picker from the
        database and manually setting it with an onchange event on the
        datasource. Very clunky.

        I don't get the second message, the difference between two dates is a
        timespan. If they are different and you are changing them the database
        does not care. If you want to make them null then the automatic
        database build will create a method SetFeildNull() and it can be checked
        with IsFieldNull().

        Ken

        Comment

        Working...