none
How to lock row in ms-access database, that other user can't access to this actually edited data row. Please I need advice for VB.net application RRS feed

  • Question

  • How to lock row in ms-access database, that other user can't access to this actualy edited data row.

    Please I need any sample for VB.net application.

    Our vb.net application is based on the many datasets.
    All these datasets are created by visual drag and drop grafical interface such as designer and wizard of vs2013?
    All forms in this our large vb.net desktop applications are based on the binding DataGridView and the binding TextBoxes.

    Please give to me any advice if somewhere in this place of code is somehow way, how to lock the row.

        Private Sub FormPridajDruhZranitelnosti_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
            If FormCiselnikDruhovZranitelnosti.ISUprav = 0 Then
                Me.DruhyZranitelnostiBindingSource.AddNew()
            Else
                AktualnaPozicia = FormCiselnikDruhovZranitelnosti.AktualnaPozicia
    
                Najdenaveta = Me.DruhyZranitelnostiBindingSource.Find("IdDruhuZranitelnosti", AktualnaPozicia)
                Me.DruhyZranitelnostiBindingSource.Position = Najdenaveta
    
            End If
            PovodnaFarbaTextBoxu = OznacenieDruhuTextBox.BackColor
        End Sub

    Najdenaveta = Me.DruhyZranitelnostiBindingSource.Find("IdDruhuZranitelnosti", AktualnaPozicia)

    Translate from Slovak language should be.

    FoundRow = Me.VulnerabilitiesBindingSource.Find ("IdKindOfVulnerability," CurrentLocation)

    Please did you yet verified my account?

    Can you please verify my account?

    Many thanks, 'cause I can't insert the picture with information about exception.










    • Edited by Vyvoj DS Wednesday, December 17, 2014 10:13 AM
    • Moved by Alex Bulankou Wednesday, December 17, 2014 4:39 PM ADO.NET question
    Wednesday, December 17, 2014 8:47 AM

Answers

  • recordlocking is based on connected data handling. 

    It was done in the time there were only 2 or 3 users really active on a database.

    Currently and that is standard with the disconnected way of datahandling optimistic concurrency is used. (record locking is pessimistic concurrency).

    Trying to tell it simple is. You take a timestamp in the database, but in fact it can also be some columns. You read them apart in your data. In the datatable that is standard done as original data.

    If you write, you first do at the same time in the sql a read to compare if the original data is changes. If that is not the case then no other user has done that.

    Here a link to see it more in depth.

    http://msdn.microsoft.com/en-us/library/vstudio/aa0416cz(v=vs.100).aspx 


    Success
    Cor

    • Proposed as answer by Fred BaoModerator Thursday, December 18, 2014 2:19 AM
    • Marked as answer by Vyvoj DS Friday, December 19, 2014 9:37 AM
    • Unmarked as answer by Vyvoj DS Friday, December 19, 2014 10:12 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:22 AM
    Wednesday, December 17, 2014 6:17 PM
  • Thank you Cor Ligthert for your fast reply.

    But I suppose that concurrency optimistic detect violation only after user press button update.

    But my boss demand any solution, that detect concurrency before user can write many data and only after that he find that his work is thrown out of the windows, but not Microsoft windows but through virtual window it is idiom it is joke of course. 

    How to tell you that you right understand me.

    We want to prefer the way where program have to detect that user 1 open specific row and for a while he don't quit work at this row nobody else (user 2 , user 3, ...) can read this row.


    • Edited by Vyvoj DS Friday, December 19, 2014 10:06 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:22 AM
    Friday, December 19, 2014 9:51 AM
  • Now when I a little think about this I find that you are possibly right.

    E. g. if I have db with one rows and plant with 1000 employs than enough that one employ open this one row and go e.g. at the dinner.

    All 999 users than have to wait if this first user came back and if he commit e.g. after  1 hour this row.

    And if user 1 came no more than all plant will stop forever.

    What is your opinion at this? 

    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:21 AM
    Friday, December 19, 2014 10:49 AM
  • Now when I a little think about this I find that you are possibly right.

    E. g. if I have db with one rows and plant with 1000 employs than enough that one employ open this one row and go e.g. at the dinner.

    All 999 users than have to wait if this first user came back and if he commit e.g. after  1 hour this row.

    And if user 1 came no more than all plant will stop forever.

    What is your opinion at this? 

    No it is worse, they even have to wait if one client orders for the row. It can be in the kitchen a while. Then the client goes away without even touching the row. Now the row is simply rolled back (unlocked) without any update. But all the time the row is unusable for others who only want to see it.


    Success
    Cor

    • Proposed as answer by Fred BaoModerator Monday, December 29, 2014 8:44 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:21 AM
    Friday, December 19, 2014 11:12 AM

All replies

  • recordlocking is based on connected data handling. 

    It was done in the time there were only 2 or 3 users really active on a database.

    Currently and that is standard with the disconnected way of datahandling optimistic concurrency is used. (record locking is pessimistic concurrency).

    Trying to tell it simple is. You take a timestamp in the database, but in fact it can also be some columns. You read them apart in your data. In the datatable that is standard done as original data.

    If you write, you first do at the same time in the sql a read to compare if the original data is changes. If that is not the case then no other user has done that.

    Here a link to see it more in depth.

    http://msdn.microsoft.com/en-us/library/vstudio/aa0416cz(v=vs.100).aspx 


    Success
    Cor

    • Proposed as answer by Fred BaoModerator Thursday, December 18, 2014 2:19 AM
    • Marked as answer by Vyvoj DS Friday, December 19, 2014 9:37 AM
    • Unmarked as answer by Vyvoj DS Friday, December 19, 2014 10:12 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:22 AM
    Wednesday, December 17, 2014 6:17 PM
  • Thank you Cor Ligthert for your fast reply.

    But I suppose that concurrency optimistic detect violation only after user press button update.

    But my boss demand any solution, that detect concurrency before user can write many data and only after that he find that his work is thrown out of the windows, but not Microsoft windows but through virtual window it is idiom it is joke of course. 

    How to tell you that you right understand me.

    We want to prefer the way where program have to detect that user 1 open specific row and for a while he don't quit work at this row nobody else (user 2 , user 3, ...) can read this row.


    • Edited by Vyvoj DS Friday, December 19, 2014 10:06 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:22 AM
    Friday, December 19, 2014 9:51 AM
  • Now when I a little think about this I find that you are possibly right.

    E. g. if I have db with one rows and plant with 1000 employs than enough that one employ open this one row and go e.g. at the dinner.

    All 999 users than have to wait if this first user came back and if he commit e.g. after  1 hour this row.

    And if user 1 came no more than all plant will stop forever.

    What is your opinion at this? 

    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:21 AM
    Friday, December 19, 2014 10:49 AM
  • Now when I a little think about this I find that you are possibly right.

    E. g. if I have db with one rows and plant with 1000 employs than enough that one employ open this one row and go e.g. at the dinner.

    All 999 users than have to wait if this first user came back and if he commit e.g. after  1 hour this row.

    And if user 1 came no more than all plant will stop forever.

    What is your opinion at this? 

    No it is worse, they even have to wait if one client orders for the row. It can be in the kitchen a while. Then the client goes away without even touching the row. Now the row is simply rolled back (unlocked) without any update. But all the time the row is unusable for others who only want to see it.


    Success
    Cor

    • Proposed as answer by Fred BaoModerator Monday, December 29, 2014 8:44 AM
    • Marked as answer by Vyvoj DS Friday, January 2, 2015 9:21 AM
    Friday, December 19, 2014 11:12 AM