| | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 06/28/2008 7:51:06 AM Posts: 36, Visits: 79 |
| | Hi Guys, As I have said before, I am a part time programmer and seem to be little rusty all of the time. With that said, after following the help instructions, I am unable to get SF concurrency using RowVersioning to work. User A and User B are editing the same record at the same time using the code below. User A saves the record. Then User B saves the record and the BO does not throw an exception. What am I doing wrong? Thanks for the help! I have the following properties set on the ContactsBO: CollisionNoficationType = ThrowException RowVersionOrTimestampColumn = ContactRowVersion (datatype int - allow nulls) UpdateConcurrencyType = OptimisticRowVersion Code Below.............................. Using loBO As New ContactsBO loBO.FillByPrimaryKey(contactID) If loBO.IsEmpty Then Return FalseElse loBO.Edit() loBO.UserID = GlobalVariables.CurrentUserID loBO.Save() Return TrueEnd IfEnd UsingCatch ex As MicroFour.StrataFrame.Data.DataLayerExceptionMsgBox( "DataLayerException ex = " & ex.Message)Return FalseCatch ex As MicroFour.StrataFrame.Data.DataLayerSavingExceptionMsgBox( "DataLayerSavingExeption ex = " & ex.Message)Return FalseCatch ex As MicroFour.StrataFrame.Data.RowNotUpdatedExceptionMsgBox( "RowNotUpdateExeption ex = " & ex.Message)Return FalseCatch ex As ExceptionEms.HandleException( Me, ex)Return FalseEnd Try |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:13:06 AM Posts: 4,104, Visits: 4,176 |
| Well the good news is that I know that there isn't an issue with the RowVersion concurrency...this is probably the most common concurrency logic used . So we will want to look at your code a little closer.First, I am not sure what you are trying to accomplish by catching all of the individual exception types...I assume that you have some need for this in your application...so we can just skip over that for now. Second, you will not want to allow NULLs on the row version field...bad mojo could come Next, you will need to indicate whether you are using CRUD settings, etc. If you are using the DDT and allowing the sprocs to be created for you, did you set the row version column on the table properties? 
You will also notice in that screen shot that the UPDATE procedure will need to have the concurrency set to Optimistic Row Version as well. Also, you should just set the BO CRUD properties on through the BO designer versus in code each time...it you are going to have the same concurrency type each time, which you should. Finally, you will want to handle the COncurrencyException event versus trying to catch the exception as you currently are. If there is a concurrency collision, the ConcurrencyException event will be raised...that is where you will want to place your logic...not a bunch of Try/Catches. Hopefully one of these suggestions should get you going.  |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 06/28/2008 7:51:06 AM Posts: 36, Visits: 79 |
| | Hi Trent, I am not using CRUD or DDT. As I show you in the code, I am just using the BO.Fill, BO.Edit and BO.Save methods to update a field. Therefore, how do I handle or trap for the concurrency issue using SF when User A and User B are editing and updating the field at the same time? Thanks. |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: 06/17/2008 9:28:35 AM Posts: 2,649, Visits: 1,863 |
| | By default, you can capture the ConcurrencyException event on the business object. When the second user goes to save and the concurrency exception is detected, that event will be raised. However, if you change the CollisionNotificationType property on the business object to ThrowException, then a DataLayerSavingException will be thrown that contains the information about the concurrency exception that was encountered. So, it's really up to you as to how you want to handle the error. If you capture the event, you can set the Resave property on the event args to True and the data layer will re-save the record after the event handler returns and you're original call to Save() will never know there was an error. If you catch the exception, then you'll need to call Save() again after you're done what you want to with the data.
www.bungie.net |
| |
|
|