Concurrency Using RowVersion Problem
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Concurrency Using RowVersion ProblemExpand / Collapse
Author
Message
Posted 03/21/2008 9:46:47 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame 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 False

Else

  loBO.Edit()

  loBO.UserID = GlobalVariables.CurrentUserID

  loBO.Save()

Return True

End If

End Using

Catch ex As MicroFour.StrataFrame.Data.DataLayerException

MsgBox("DataLayerException ex = " & ex.Message)

Return False

Catch ex As MicroFour.StrataFrame.Data.DataLayerSavingException

MsgBox("DataLayerSavingExeption ex = " & ex.Message)

Return False

Catch ex As MicroFour.StrataFrame.Data.RowNotUpdatedException

MsgBox("RowNotUpdateExeption ex = " & ex.Message)

Return False

Catch ex As Exception

Ems.HandleException(Me, ex)

Return False

End Try

Post #15079
Posted 03/21/2008 10:07:01 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 9:47:36 PM
Posts: 4,115, Visits: 4,185
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.

Post #15084
Posted 03/22/2008 10:45:57 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame 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.

Post #15114
Posted 03/24/2008 8:32:29 AM


StrataFrame Developer

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
Post #15123
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 2:20am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 9 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.