Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have two applications that access the same database. The database is MySql. I want that when one application is updating a table then the second application cannot access that table.
How this can be done in Ado.net?
Posted

Google for SQL lock...

Read this: Understanding Locking in SQL Server[^]
 
Share this answer
 
v2
See here[^] or here[^].
 
Share this answer
 
but how do we implement these locks using ADO.NET?
 
Share this answer
 
Comments
Sandeep Mewara 29-Aug-10 10:58am    
1. Don't push answer button when actually it is a comment to an answer
2. You will put locks on columns in DB & queries you will use. Didn't you look at the links?
Usama Aziz 29-Aug-10 12:37pm    
i look3at the links but i want to know how these can be implemented in through ado.net. basicaaly some sort of example code will be helpful
ok..it would be good if you did such a thing in the database itself but if you want to do things on the front-end level, then you'd have to do a bit of 'illegitimate' coding as I personally like to call it..and you can do so in these steps..

1. Instead of using a connected-environment, rather opt for a disconnected-environment (datasets)..

2. Now put every database action on a thread pool, so assign priorities to your threads ( so the action with the current connection has the highest priority etc), and then afterwards you can switch priorities after the action is completed to the next database action in the pool..

3. The multiple threads will create a sort of locking, but I must warn that this wont be something a programmer with less time on his hands ( and less programming knowledge would want to attempt)..

Its just an alternative course (thats why programmers are so diverse and gr8!)..but I would advice you to stick to doing it in the database..
 
Share this answer
 
Comments
Usama Aziz 30-Aug-10 12:34pm    
how this can be done at database level?
thanks in advance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900