Concurrency Using RowVersion Problem


Author
Message
Jeff Pagley
Jeff Pagley
Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)Advanced StrataFrame User (641 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
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


Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 Smile.  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 BigGrin  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. Smile

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search