Re: Online activity
Chris Anderson <[email protected]> Sun, 11 Oct 2009 16:18:43 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Instead of using a basic bit flag, use the userid as the flag. i.e. : UPDATE table SET lockedByUser =3D <userId> WHERE rowId =3D <editRow> AND (lockedByUser IS NULL OR lockedByUser=3D<userId>) Then either read the row data to see if you have the lock, or check how many rows were affected (0 or 1) The above technique allows only a single user to pass the check and is resilient to browser windows closing, session timeouts, etc The flag will remain indefinitely unless you separately clear flags (perhaps also include a lockTime so you know which are old and stale), but will always allow the user that created the lock to re-apply for the edit mode, and to clear the flag in the usual way (i.e. after hitting save or cancel) > -----Original Message----- > From: Discussion of advanced .NET topics. [mailto:ADVANCED- > [email protected]] On Behalf Of Paul Cowan > Sent: 11 October 2009 09:01 > To: [email protected] > Subject: [ADVANCED-DOTNET] Online activity >=20 > Hi, >=20 > I am working on an application where different users will process > different > database records off a web page. >=20 > They will select different records from a grid on a web page and then > complete the details before saving. >=20 > My question resolves around how I can stop 2 different users accessing > the > same record at the same time. >=20 > I could have a flag in place that signifies that the record is being > worked > on but there are edge cases surrounding this approach. >=20 > My worry is that a user might start processing a record and then for > whatever reason just finish the browser session without actually > finishing > the record and the flag will remain as being processed. >=20 > I am sure this is quite a common use case. Any ideas? >=20 > Cheers >=20 > Paul Cowan >=20 > Cutting-Edge Solutions (Scotland) >=20 > http://thesoftwaresimpleton.blogspot.com/ >=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > View archives and manage your subscription(s) at > http://peach.ease.lsoft.com/archives >=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives