How to Lock a database table from being accessed by multiple clients?
-
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
-
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
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.
-
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
With a transaction, as mentioned, but clients can still use WITH(NOLOCK) in a SELECT statement to ignore your lock when reading.