Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / June 2004

Tip: Looking for answers? Try searching our database.

lock records for update: how? options?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
feng - 18 Jun 2004 14:58 GMT
Hi,

I know ADO.Net recommand using disconnected update
(optimistic concurrency) for good reasons, but it's just
not an option for us. 99% of our client would rather  
seeing "record locked" kind of message up front when they
load records, than being told "updating failed" after they
spend all the time entering the data.

So here I am spending a lot of time trying to find a good
way to do the "read with lock" type of opration. I know
you can do some thing like that, at the query level, if
you are running some late version of SQL server, but what
if I can't use those DB specific features? Is there a
recommanded way of doing this at ADO.Net level"? What
about ADO.Net's transaction?

If someone can point me to a right direction that would be
highly appreciated!

Thanks

Feng
Miha Markic [MVP C#] - 18 Jun 2004 21:33 GMT
Hi feng,

I would suggest you to reason the client.
Example: a guy opens some data for editing and goes eating lunch. Now, the
whole system might be locked because of this until he eats all the lunch...

Signature

Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

> Hi,
>
[quoted text clipped - 19 lines]
>
> Feng
Marina - 18 Jun 2004 21:41 GMT
I would be careful with all these locks, as what tends to happen is that a
whole page gets locked, and then you can't even access other records that
just happen to be located on the same page.
Keeping transactions open just for the locking will also cause these sorts
of problems - and trust me, you do not want to be dealing with them.

One way to "lock" a record, is in a transaction to change some field in the
database to the name of the user that locked it if the field is empty (or
something like this).  Using a transaction should mean that only the first
user gets the update in, and the second fails because now the first user
locked the record.

Then you would "unlock" it by clearing out the field.

Of course as someone else mentioned, if someone opens a record and leaves,
well, then the record will be unavailable, and you will run into all sorts
of problems.  So I would also recommend not using this approach, but if you
have to, I would avoid using database locking mechanisms to accomplish this.

> Hi,
>
[quoted text clipped - 19 lines]
>
> Feng

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.