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. Web Development
  3. ASP.NET
  4. Multiple updates

Multiple updates

Scheduled Pinned Locked Moved ASP.NET
csharpquestionannouncement
7 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.
  • P Offline
    P Offline
    Paul Riley
    wrote on last edited by
    #1

    Does anyone know this? If I have a dataset as an application-scoped object, can I use C#'s lock() command on a datatable to make sure that no two users update the table at the same time? It makes sense that I can, being essentially the same as threading, but I can't find confirmation anywhere. Paul

    J 1 Reply Last reply
    0
    • P Paul Riley

      Does anyone know this? If I have a dataset as an application-scoped object, can I use C#'s lock() command on a datatable to make sure that no two users update the table at the same time? It makes sense that I can, being essentially the same as threading, but I can't find confirmation anywhere. Paul

      J Offline
      J Offline
      Jason McBurney
      wrote on last edited by
      #2

      Why not just use transaction processing? The database knows what it can thread together and what it can not. (They are very smart)

      P 1 Reply Last reply
      0
      • J Jason McBurney

        Why not just use transaction processing? The database knows what it can thread together and what it can not. (They are very smart)

        P Offline
        P Offline
        Paul Riley
        wrote on last edited by
        #3

        Jason McBurney wrote: Why not just use transaction processing? Because it's not that simple. If two users are updating the same table, it's possible that the first user will call for an update while the other is still editing a record. Or in another scenario, it's possible that two users can do an update and then check for the same "everyone is done here" condition and it become true for both of them instead of only one. I want to lock someone out from editing a table completely while any other user is in the middle of processing the same table. In the worst case, I can do this by having a bunch of flags, also in the Application scope. But if lock() works then there's no need to do that. I suspect I might have to run some tests. Paul

        J 1 Reply Last reply
        0
        • P Paul Riley

          Jason McBurney wrote: Why not just use transaction processing? Because it's not that simple. If two users are updating the same table, it's possible that the first user will call for an update while the other is still editing a record. Or in another scenario, it's possible that two users can do an update and then check for the same "everyone is done here" condition and it become true for both of them instead of only one. I want to lock someone out from editing a table completely while any other user is in the middle of processing the same table. In the worst case, I can do this by having a bunch of flags, also in the Application scope. But if lock() works then there's no need to do that. I suspect I might have to run some tests. Paul

          J Offline
          J Offline
          Jason McBurney
          wrote on last edited by
          #4

          Isn't that what the 2PL locking algrithum is all about. I am almost sure that the database will deal with this correctly.

          P 1 Reply Last reply
          0
          • J Jason McBurney

            Isn't that what the 2PL locking algrithum is all about. I am almost sure that the database will deal with this correctly.

            P Offline
            P Offline
            Paul Riley
            wrote on last edited by
            #5

            Hi Jason, The problem is that all the data is in a DataSet in the Application and I'm using DataAdapters to run any updates made in the page. There's no way that the database can have any idea what I'm doing until I run the updates. By then it's too late. I may be missing something here (I hope so!) but I don't think so. Paul

            J 1 Reply Last reply
            0
            • P Paul Riley

              Hi Jason, The problem is that all the data is in a DataSet in the Application and I'm using DataAdapters to run any updates made in the page. There's no way that the database can have any idea what I'm doing until I run the updates. By then it's too late. I may be missing something here (I hope so!) but I don't think so. Paul

              J Offline
              J Offline
              Jason McBurney
              wrote on last edited by
              #6

              ... From your other posts, I am assuming that you are editing the data, and not the schema of the database. Additionally this issue you are facing is exactally how the dissconnected ADO classes are designed to work (or So the Micro$oft peps claim) Use the force young Riley, run your test and I think you will find that the solution will be resolved with ADO correctly. Even if two individuals do grab the same row R and edit it. Alice will change R to C Bob will change R to B Then At compleation the row needs to be either B or C. Thus giving you this effect Alice writes Bob Writes Alice Refreshes (and sees row B) if this order of events you feel this is wrong then there needs to be database level locks ( for your application). These locks would tel bob's application that row R is not modifible at this time because it is "checked out" by Alice.

              P 1 Reply Last reply
              0
              • J Jason McBurney

                ... From your other posts, I am assuming that you are editing the data, and not the schema of the database. Additionally this issue you are facing is exactally how the dissconnected ADO classes are designed to work (or So the Micro$oft peps claim) Use the force young Riley, run your test and I think you will find that the solution will be resolved with ADO correctly. Even if two individuals do grab the same row R and edit it. Alice will change R to C Bob will change R to B Then At compleation the row needs to be either B or C. Thus giving you this effect Alice writes Bob Writes Alice Refreshes (and sees row B) if this order of events you feel this is wrong then there needs to be database level locks ( for your application). These locks would tel bob's application that row R is not modifible at this time because it is "checked out" by Alice.

                P Offline
                P Offline
                Paul Riley
                wrote on last edited by
                #7

                If you're right, Jason, I'm going to be a very impressed and happy camper. I'll give this some heavy testing later in the week. Cheers. Paul

                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