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. How to Lock a database table from being accessed by multiple clients?

How to Lock a database table from being accessed by multiple clients?

Scheduled Pinned Locked Moved C#
databasecsharpsql-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.
  • N Offline
    N Offline
    nilam2477
    wrote on last edited by
    #1

    I have a application wherein database is located on server and there are client computer which access the central database server. How to handle a situation when more than one client tries to access the same data table on the server. I'm using SQL Server 2005. It it internally handled in SQL 2005? or i need to handle in my C# code? Please help

    M P 2 Replies Last reply
    0
    • N nilam2477

      I have a application wherein database is located on server and there are client computer which access the central database server. How to handle a situation when more than one client tries to access the same data table on the server. I'm using SQL Server 2005. It it internally handled in SQL 2005? or i need to handle in my C# code? Please help

      M Offline
      M Offline
      Mirko1980
      wrote on last edited by
      #2

      In SQL, you can use Transactions to manage concurrency during operations. You can also lock entirely a table during an inret or update by using the WITH TABLOCK clause at the end of your query. If you want to do it in your C# code, look at the TransactionScope class.

      1 Reply Last reply
      0
      • N nilam2477

        I have a application wherein database is located on server and there are client computer which access the central database server. How to handle a situation when more than one client tries to access the same data table on the server. I'm using SQL Server 2005. It it internally handled in SQL 2005? or i need to handle in my C# code? Please help

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        With a transaction, as mentioned, but clients can still use WITH(NOLOCK) in a SELECT statement to ignore your lock when reading.

        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