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. General Programming
  3. C#
  4. C# and MS SQL DeadLock

C# and MS SQL DeadLock

Scheduled Pinned Locked Moved C#
databasecsharptutorial
4 Posts 4 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.
  • Z Offline
    Z Offline
    Zeyad Jalil
    wrote on last edited by
    #1

    Hi All, I use a MS SQL Database with Windows Application c# and I need to manage the deadlock of my table of multiple users insert into this table in the same time, I need to check if the table was deadlock at each save before insert into it, and i don't need to depend on the Try catch block (dead lock exception). Please let me know how to Solve it. Thank you

    P L A 3 Replies Last reply
    0
    • Z Zeyad Jalil

      Hi All, I use a MS SQL Database with Windows Application c# and I need to manage the deadlock of my table of multiple users insert into this table in the same time, I need to check if the table was deadlock at each save before insert into it, and i don't need to depend on the Try catch block (dead lock exception). Please let me know how to Solve it. Thank you

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You can't check for a deadlock and then perform an action as these are two discrete operations. In other words, in the period between you somehow performing the check and then performing the save, another operation may have deadlocked the table. You can pretty much only react to the deadlock.

      This space for rent

      1 Reply Last reply
      0
      • Z Zeyad Jalil

        Hi All, I use a MS SQL Database with Windows Application c# and I need to manage the deadlock of my table of multiple users insert into this table in the same time, I need to check if the table was deadlock at each save before insert into it, and i don't need to depend on the Try catch block (dead lock exception). Please let me know how to Solve it. Thank you

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Use "transactions"; you know: "commit" and "roll-back"?

        1 Reply Last reply
        0
        • Z Zeyad Jalil

          Hi All, I use a MS SQL Database with Windows Application c# and I need to manage the deadlock of my table of multiple users insert into this table in the same time, I need to check if the table was deadlock at each save before insert into it, and i don't need to depend on the Try catch block (dead lock exception). Please let me know how to Solve it. Thank you

          A Offline
          A Offline
          Andrea Simonassi
          wrote on last edited by
          #4

          Hello, are you sure it's a deadlock or it is a generic timeout? A table can't deadlock just because many users try to insert. Deadlock means someone is blocking record A then try to lock record B while other process locked B then try to lock A. If that happens just have both the process lock the resources in the same order (first A then B) this will avoid the deadlock, by definition, and can be done saving all records sorted by primary key, for example, within a trasaction. Best Regards Andrea

          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