Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Concurrency violation on update command.

Concurrency violation on update command.

Scheduled Pinned Locked Moved Database
databasecsharphelpsharepointvisual-studio
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    msx23
    wrote on last edited by
    #1

    Hi all, I'm having a problem with updating a row in the table when the value was originally NULL. Using c# and Visual Studio 2005 by the way. Through my front end I can modify existing values and commit those changes to the database just fine, but the problem arises when I try and change a field that was NULL to a non-NULL value. (Oh, I can also change a field that has a value to NULL just fine) When I get to my DbAdapter.Update(DATASET HERE); line I catch an exception with the following text: "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." And the thing is, when I comment out (of the update stored procedure in SQL) the part of the WHERE clause that states ((@IsNull_FIELDNAME = 1 AND [FIELDNAME] IS NULL) OR ([FIELDNAME] = @Original_FIELDNAME))where FIELDNAME is the one field that I'm trying to update, it works fine. I can't figure out why that WHERE clause is failing. I'm not updating the database anywhere else in the code other than the one spot that is failing out when I try and fill a previously NULL field. I've used VS2005's auto-generating wizard to create my stored procedures and command generators so there isn't any disagreement between the table/SP/c# that I can find. When I breakpoint at the DbAdapter.Update(DATASET HERE); line my dataset has the right values in it. Does anyone have any ideas? I'm pretty stuck here. Thanks

    R 1 Reply Last reply
    0
    • M msx23

      Hi all, I'm having a problem with updating a row in the table when the value was originally NULL. Using c# and Visual Studio 2005 by the way. Through my front end I can modify existing values and commit those changes to the database just fine, but the problem arises when I try and change a field that was NULL to a non-NULL value. (Oh, I can also change a field that has a value to NULL just fine) When I get to my DbAdapter.Update(DATASET HERE); line I catch an exception with the following text: "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." And the thing is, when I comment out (of the update stored procedure in SQL) the part of the WHERE clause that states ((@IsNull_FIELDNAME = 1 AND [FIELDNAME] IS NULL) OR ([FIELDNAME] = @Original_FIELDNAME))where FIELDNAME is the one field that I'm trying to update, it works fine. I can't figure out why that WHERE clause is failing. I'm not updating the database anywhere else in the code other than the one spot that is failing out when I try and fill a previously NULL field. I've used VS2005's auto-generating wizard to create my stored procedures and command generators so there isn't any disagreement between the table/SP/c# that I can find. When I breakpoint at the DbAdapter.Update(DATASET HERE); line my dataset has the right values in it. Does anyone have any ideas? I'm pretty stuck here. Thanks

      R Offline
      R Offline
      Rami Said Abd Alhalim
      wrote on last edited by
      #2

      you can using isnull fungtion to check on null isnull([FIELDNAME], @Original_FIELDNAME,FIELDNAME)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups