﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » How to disallow user to edit a record if another user is already editing that record?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 14 Sep 2026 17:26:52 GMT</lastBuildDate><ttl>20</ttl><item><title>How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7570.aspx</link><description>Respected Sir/Madam,&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
We are using SF with our project.&lt;br&gt;
we just have developed a windows application that will run on different machine on a Local are network with central Database present at server. Now, as all user can add, view, edit, update all the records so i don't want any user to edit a record if any other user is already been editing that record. i just wanna show him a message when he/she clicks edit that "Any other user is already editing this records so you can't edit this record." Please tell me how can i achieve this kind of functionality using SF.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Aman.</description><pubDate>Mon, 26 Mar 2007 13:19:39 GMT</pubDate><dc:creator>Vikram Saxena</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7696.aspx</link><description>Hi Pertti.&lt;P&gt;For some scenarios, this looks great! I can think of one place I'm going to use it.&lt;P&gt;Thanks for sharing.</description><pubDate>Mon, 26 Mar 2007 13:19:39 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7691.aspx</link><description>Here's a technique I've used&amp;nbsp;with VFP:&lt;/P&gt;&lt;P&gt;Use a VFP "lock table" which has&amp;nbsp;entries for rows that are locked, who locked them and when, and any other information you care to put in there.&amp;nbsp; Since Strataframe can open VFP&amp;nbsp;databases along with any other databases, this can work in many scenarious.&lt;/P&gt;&lt;P&gt;Here's the simplistic pseudo code:&lt;/P&gt;&lt;P&gt;1. Ready to edit a row, check VFP lock table to see if that row is in there AND if it is locked by someone else.&lt;/P&gt;&lt;P&gt;2. If it is there and locked, do not allow concurrent editing, notify user trying to lock it&lt;/P&gt;&lt;P&gt;3. If it is there and not locked, lock it, write pertinent information into the lock record and open row for editing&lt;/P&gt;&lt;P&gt;4. If it is not there, locate another lock table record that is not locked and recycle it and go to 3.&amp;nbsp; If there is no recycleable (non-locked) record available, create a new one and go to 3.&lt;/P&gt;&lt;P&gt;The beauty of this approach is that it is dynamic -- if your app crashes or "forgets" to UNLOCK the locktable entry when done with it, VFP releases the lock as soon as the application exits, one way or another.&amp;nbsp; This approach avoids the cleanup mess (!), but can still accidentally leave a record locked for the duration of the session if you are don't pay attention to the unlock action in the save/discard row procedures.&lt;/P&gt;&lt;P&gt;Pertti</description><pubDate>Mon, 26 Mar 2007 11:26:30 GMT</pubDate><dc:creator>Pertti Karjalainen</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7645.aspx</link><description>Correct...NULL values are not supported on the Row Version column.&amp;nbsp; Thanks, Greg :D</description><pubDate>Wed, 21 Mar 2007 10:46:02 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7643.aspx</link><description>One other thing: the row version column needs to be 0 initially. I.e.&lt;br&gt;
&lt;br&gt;
RowVersion int Not Null CONSTRAINT def_rowversion DEFAULT (0)</description><pubDate>Wed, 21 Mar 2007 10:35:42 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7638.aspx</link><description>By default StrataFrame BOs automatically implement AllRowsOptimistic concurrency.&amp;nbsp; However, this is not the most efficient way.&amp;nbsp; The best type of concurrency is using a row version.&amp;nbsp; To do this, just add a single integer field in your table.&amp;nbsp; Once added, rebuilt your partial class for the BO so the new field is recognized.&amp;nbsp;&amp;nbsp; Double-click the BO you are working on and go to the RowVersionOrTimeStamp property and set it to the name of the integer field you have just added to your table.&amp;nbsp; Next, set the UpdateConcurrencyType to OptmizsticRowVersion....and that's it!&amp;nbsp; The BOs and data access layer will handle the rest.&amp;nbsp; If you have a concurrency collision the BOs ConcurrencyException event will be raised.&amp;nbsp; By default, the UI will automatically show the concurrency exception form to the end-user,&amp;nbsp; If you wish to manage this yourself then you just set the AutoShowConcurrencyExceptions property on the form to false and manage the ConcurrencyException event yourself.</description><pubDate>Wed, 21 Mar 2007 06:51:21 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7637.aspx</link><description>Thanks Ben!!&lt;br&gt;
&lt;br&gt;
now i think i should go for default concurrency model of SF but,..but i don't know how can i achieve this model in my project. can you please explain this to me... &lt;br&gt;
&lt;br&gt;
Thanks in Advance....</description><pubDate>Wed, 21 Mar 2007 04:32:09 GMT</pubDate><dc:creator>Vikram Saxena</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7577.aspx</link><description>[quote]I will caution you against this type of functionality as it goes against the purpose of concurrency and can potentially leave records "locked" if there is some type of error.  I recommend using the built in concurrency rather than this methodology.[/quote]&lt;br&gt;
&lt;br&gt;
As Trent has pointed out, "Hard Lock" can eventualy drive you crazy, due to some issues remaining there. I had my share of problems many years ago, and I won't do it again.&lt;br&gt;
&lt;br&gt;
Just my 2 cents!</description><pubDate>Mon, 19 Mar 2007 09:56:59 GMT</pubDate><dc:creator>Ben Hayat</dc:creator></item><item><title>RE: How to disallow user to edit a record if another user is already editing that record?</title><link>http://forum.strataframe.net/FindPost7571.aspx</link><description>Well, this goes beyond concurrency.&amp;nbsp; StrataFrame has teh ability to handle concurrency so if two users modify the same data, it will raise the ConcurrencyException event (and even manage it for you if you by default).&amp;nbsp; However, if you do not want to use concurrency and just have a "hard" lock on the record when editing, you will have to add another field to the table and update that field when the end-user edits the BO.&lt;/P&gt;&lt;P&gt;You would have to handle the EditingStateChanged event in the BO to determine when you are editing.&amp;nbsp; Within this event if you are editing you would want to update that single field back on the database.&amp;nbsp; You will need to do this outside of the BO otherwise the state will change back.&amp;nbsp; Wheh I say outside of the BO, I just mean you will need to use a connection and command object manually.&amp;nbsp; HOwever, you will already have the connection string the in DataSources collection which can be used within the connection object.&lt;/P&gt;&lt;P&gt;[codesnippet]'-- Establish Locals&lt;BR&gt;Dim loCommand As New SQLCommand()&lt;BR&gt;Dim loConn As New SQLConnection(MicroFour.StrataFrame.Data.Databasics.DataSources(0).ConnectionString)&lt;/P&gt;&lt;P&gt;loCommand.CommandText = "UPDATE MyTable SET MyField = MyValue WHERE MyPrimaryKey = MyPKValue"&lt;/P&gt;&lt;P&gt;'-- Open the connection&lt;BR&gt;loConn.Open()&lt;/P&gt;&lt;P&gt;'-- Set the connection on the command&lt;BR&gt;loCommand.Connection = loConn&lt;/P&gt;&lt;P&gt;'-- Execute the query&lt;BR&gt;loCommand.ExecuteNonQuery()&lt;/P&gt;&lt;P&gt;'-- Close the connection&lt;BR&gt;loConn.Close()[/codesnippet]&lt;/P&gt;&lt;P&gt;When the state goes back to Idle, you will then just reset the flag back to a "allow edit" state.&amp;nbsp; I will caution you against this type of functionality as it goes against the purpose of concurrency and can potentially leave records "locked" if there is some type of error.&amp;nbsp; I recommend using the built in concurrency rather than this methodology.</description><pubDate>Mon, 19 Mar 2007 07:54:16 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>