views:

49

answers:

1

I am developing three applications that all share a common database.
I'm running into many different concurrency issues and was wondering if it is possible to prevent any other queries to execute when certain queries are running (in other words, locking the database so there won't be any concurrency issues).

Edit: I'm using LINQ to SQL

+2  A: 

You can always use TransactionScope together with the appropriate locking hints to lock people out. Now, the question is why you would want to do that...

...a better approach might be to do your own soft-locking mechanism, i.e. a table where you can insert a flag that a certain operation is under way and then have others check that table before doing something that could conflict with that operation.

Using DB locks for this should be a last resort.

See:
http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/2d6fdb2e-e17e-4a4c-8da0-6968e60ef855
...and...
http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/1b20c00d-bb53-4057-a336-79d962eb463f

KristoferA - Huagati.com