Results 1 to 7 of 7

Thread: Concurrency issues

  1. #1
    Join Date
    Jul 2006
    Posts
    276
    Rep Power
    0

    Default Concurrency issues

    I am having a weird problem

    Database: MS ACCESS 2007

    Language: VB.Net 2003

    Error: System.Data.DBConcurrency Exception
    Concurrency violation: the DeleteCommand affected 0 records

    After adding and saving a new record:

    me.bmb.endcurrentedit()
    me.da.update(me.ds, "tblMembers")


    Then after moving to another record and back to the record; after clicking on delete:

    me.bmb.endcurrentedit()
    me.bmb.removeat(me.bmbposition)
    me.da.update(me.ds, "tblMembers") ' get the error here]

    I immediately receive the concurrency error

    Can anyone tell me wats the problem, because it works well if i close the application or leave the form and return to it, the delete works.
    The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!

  2. #2
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    I can see you using the binding manager base. Can I ask why? We learnt that at UTECH but it's not a flexible option. Use a dataset. As for accessing Access 2007 database, you may need a newer version of MDAC. Search for it at microsoft website.
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

  3. #3
    Join Date
    Jul 2006
    Posts
    276
    Rep Power
    0

    Default

    Quote Originally Posted by psybuck2002us View Post
    I can see you using the binding manager base. Can I ask why? We learnt that at UTECH but it's not a flexible option. Use a dataset. As for accessing Access 2007 database, you may need a newer version of MDAC. Search for it at microsoft website.
    well i am using a dataset? access 2007 isnt the problem either tried it on a 2003 database same problem.
    The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!

  4. #4
    Join Date
    Feb 2005
    Posts
    85
    Rep Power
    0

    Default

    This is an ugly solution but try this:

    After the user confirms the delete

    1)store the primary key for that record in memory

    2) either refresh the dataset or close & re-open the form - then go back to the record with that primary key

    3) delete the record
    Code King aka Code WizZzard: Motivated By The Challenge, Driven By The Will To Succeed.

    In The Land Of Programmers, The Code WizZzard Is KING. Sen on anything VB

  5. #5
    Join Date
    Jul 2006
    Posts
    276
    Rep Power
    0

    Default

    solution found i think hope it doesnt reappear itself

    after saving the document

    me.da.update(me.ds, "tblMembers")

    'I dipose the dataset and fill it back agen

    ds.dispose
    FillTables() 'which is a function i use to fill the dataset
    The greatest discovery of all men through lifetime is that a man can alter his life by altering his attitude!

  6. #6
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    you shoud have ensured the record is updating itself (or at least the primary key) when it inserts/updates.

    just look at the insert command if it "select * fromtable where id = @@Identity" after the actual insert. or if you passed the id parameter as output look for (or add) select @Id = @@Identity.

    the problem is that if a generated id is not sent back to the record, then id would not be found when you try to delete. hence 0 rows.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

  7. #7
    Join Date
    Feb 2005
    Posts
    85
    Rep Power
    0

    Default

    Last edited by ToxXxic; Feb 21, 2008 at 09:02 AM.
    Code King aka Code WizZzard: Motivated By The Challenge, Driven By The Will To Succeed.

    In The Land Of Programmers, The Code WizZzard Is KING. Sen on anything VB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •