Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
How we can achieve read lock in database access. I have a program with 4 instances of it, i want to implement read lock like:
-> when one instance access the table no other instance could not be accessed even for reading from the table.
-> Each instance can be used different transactions, only one transaction can have the access to the table. (only one transaction in one instance)
-> the table can be accessed only after committing the transaction used by the current instance.

I am doing this using ado.net. Now i am using
myTransaction = mySQLConnection->BeginTransaction(System::Data::IsolationLevel::Serializable);

this isolation level, but this will allow the other instances to read from the table, i wants to lock even the read. How can we achieve this.??? Is this possible in any way???
Posted
Updated 2-Dec-14 2:39am
v2

1 solution

 
Share this answer
 
Comments
Member 11168418 3-Dec-14 3:41am    
i have used the XLOCK hint like:
select * from [myTable] with (XLOCK)
So even read is not possible for other transaction, thats fine..
What is the same implementation of oracle???
FOR UPDATE is there, can we use this while connecting the db through network.?

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