January 11, 2012 at 1:50 am
Hi
I want to lock some group of data when some user monitoring this data group on winform. When other user want to monitoring same data i want to throw exception. "This data group open on USER A."
What i need to do? How do i ensure this model in MS SQL
January 11, 2012 at 2:04 am
You can add a column to the table called Locked with default value N.
When you read it for monitoring, change the column value to Y.
If value is Y, don't allow others to read it.
Once monitoring it over, revert the value to N
January 11, 2012 at 2:10 am
Suresh B. (1/11/2012)
You can add a column to the table called Locked with default value N.When you read it for monitoring, change the column value to Y.
If value is Y, don't allow others to read it.
Once monitoring it over, revert the value to N
If you go that route, be very, very, very careful with error handling. Make sure that there's no way that an error can result in the monitoring ending with the locked still set to Y. You may also need a scheduled job to set the locked back to N in case the client crashes or stuff like that.
If I recall, there's an entire chapter on this in Adam Machanic's "Expert SQL Server 2005 Development" (not the 2008 one). It's far from as simple a most people tend to assume
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 11, 2012 at 2:32 am
Of course i thought this simple model. But it's need to some kind of time out model. As GilaMonster said.
I interesting maybe sql provide this kind of model in default.
January 11, 2012 at 3:13 am
You can use the applock feature (see Books Online for details), but it still requires some custom code.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 11, 2012 at 7:22 am
Yes. I read this feature. I'll look what i can do. Thanks
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply