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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Control editing rows in Server and client projects

Control editing rows in Server and client projects

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
3 Posts 3 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.
  • V Offline
    V Offline
    vahidfallahi
    wrote on last edited by
    #1

    Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

    W M 2 Replies Last reply
    0
    • V vahidfallahi

      Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Do you really mean that other clients won't be able to modify the record while it's under editing at some client or that if 2 clients modify the same record, the program can notice this. Typically it's the later choice. The latter choice can be achieved using optimistic locking. Add a timestamp column (if SQL Server) to your table which will change every time the record is modified. Now always when updating or deleting, include the value of the timestamp column in the where condition. This way you'll notice if something has changed. The first one can be done using locking. First you lock the record (for example using update), you keep the transaction open, make modifications in UI and then update again and if everything is fine, commit otherwise rollback. However there should never be UI conversations in the middle of a transaction. This will typically cause many problems. If you're not connected to the database, another process can hold the lock while editing is done. There are of course several other possibilies and especially if you're talking about offline appplication then factors like how long time between connections how much modifications etc will affect the choice. If the amount of time between edit start and end is long then locking isn't a good choice.

      The need to optimize rises from a bad design.My articles[^]

      1 Reply Last reply
      0
      • V vahidfallahi

        Hi to codeproject world! i have a project with sql server 2008 which has a server and 5 client. [i mean that the project i have written is running on 6 pc's(one server and 5 client)] now my problem is when the client1 is editting a record ( for exm:- Id:12 , from table1 ) other 4 client and sever should not have permission to edit that record. hint : i send Id to sql and get record and then i start to edit. at that time i am not connected to sql..

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Be very sure this is a real world issue, not just an excercise in theoretical design question on how to build a bulletproof data entry system. Over many years and some fairly high volume data entry apps I have never, not once, had to implement a locking structure to secure against simultaneous editing. I once wrote a system that kept track of the occurrence of data conflicts to assess their impact. The tracking system ran for 3 weeks and recorded 2 incidents, on a very high volume travel booking system, some twat of a manger had predicted multiple conflicts every hour. When the cost of the tracking was factored in management discarded it. So make sure you (probably some manager somewhere) are not just wasting your time on unrealistic problems.

        Never underestimate the power of human stupidity RAH

        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