Question Alert concurrency

jairaj.net

New member
Joined
May 21, 2011
Messages
2
Programming Experience
1-3
hi All,
i am developing an multi user application.
now, i have one big issue...
when one user is working on any row of any table and at the same time some other user changed the data of particular Record. so i want to make any procedure to stop the other user to change that record or display an Alert window to the first user that "data has Changed !"

can anyone please help me out ?

Thanks in Advance.
 
What you're talking about is not generally feasible. It is possible if you're talking about a very small number of users if you use the SqlDependency class, but it was not designed for client apps that connect to the database directly.
MSDN said:
SqlDependency was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have SqlDependency objects set up for a single database server.
Generally speaking, the situation you're talking about should be handled at the point that the user tries to save changes, using optimistic concurrency. When the data is saved, the system checks the original values for the record in the application against the current values in the database. If they are the same, the record is updated. If they are not the same, a concurrency violation occurs and an exception is thrown. Your application catches that exception, notifies the user and provides the appropriate options. One of those options would generally be to get the current data from the database and re-edit. You can discard the changes they have made or you can merge those changes with the incoming data. You can read more about optimistic concurrency and how to implement it in .NET at MSDN or on the web in general.
 
thanks jmcilhinney

thanks for your reply....
i think you are right. i am currently using this mechanism in my software. but i wanted more features..
anyways Thanks a Lot !:cool:
 
Back
Top