Concurrency question


Author
Message
Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
I have a question reguarding concurrency

i have 2 business objects both use stored procedures to do an update

if in my SP I have  "SET NOCOUNT ON" it fires

 the form showning the user that a data collision has occurred and asking them to choose the value. 

could you explain why this is ?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This is default behavior.  If you do not want the form to pop up allowing the end-user to choose which value, you can turn off the AutoHandleCollisions property on the form and then manage the ConcurrencyException event yourself to take whatever action you would like.

As for your SP, use the DDT to create stored procedures for you at least once, even if it is a test profile, so you can see what is expected on the StrataFrame CRUD settings side if you are creating them yourself. 

Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
I understand that this is the default behavior, what i would like to know is why

SET NOCOUNT   effects the busines object and seems to cause the collisions

Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
I also seem not to be able to get back my GUID which is assigned by

the server with a call to "NEWID()" in my stored proc. Below is a zip file with

the relevant files.

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Bradley,

The zip file didn't get attached, would you mind posting it again? 

The reason that SET NOCOUNT ON causes the business object to think that there is a concurrency exception is that the DAL tests the ExecuteNonQuery() return value to determine how many records were affected by the query.  If SET NOCOUNT ON is used, then an UPDATE returns 0 records modified, so the business object thinks that no records were updated... meaning there was a concurrency excepton. 

SET NOCOUNT ON is fine for sprocs that return result sets or single values, but CRUD sprocs require the rowcount to determine whether or not they went through.

Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
Sorry I must have forgot to attach it.

Seems like you cannot edit posts so here it is.

Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
Sorr lets try it one more time
Attachments
projzip.zip (136 views, 61.00 KB)
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You'll need to set your PrimaryKeyIsAutoIncremented property to True.  This tells the DAL to consider the PK to be an output parameter and retrieve it after the record is inserted.  You have to be using stored procedures to do a server assigned GUID PK that is auto-retrieved (so you're good to go).  Also, if you want to remove your NULLIF(@CustomerID, '00000000-0000-0000-0000-000000000000'), you can set the Me.CustomerID = DBNull.Value in the SetDefaultValues() of the business object.
Bradley Marston
Bradley Marston
StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)StrataFrame Novice (58 reputation)
Group: Forum Members
Posts: 24, Visits: 119
I tried setting PrimaryKeyIsAutoIncremented  to true

it does not seem to help. I still show customer_uid =

'00000000-0000-0000-0000-000000000000'  and debug output shows

Direction: Input on customer_uid

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The SqlDataSourceItem class is creates the paramters like this:

For Each lcField In QueryInfo.PrimaryKeyFields
loParam = Me.CreateDbParameter(QueryInfo, lcField)
loParam.ParameterName = "@" & lcField
loParam.SourceColumn = lcField
If QueryInfo.PrimaryKeyFieldIsAutoInc Then
loParam.Direction = ParameterDirection.Output
Else
loParam.Direction = ParameterDirection.Input
End If
loReturn.Parameters.Add(loParam)
Next

So, I'm not sure why the parameter direction is still Input.  It should be Output.  As for the GUID being initialized to 00000000-0000-0000-0000-000000000000, I believe I told you incorrectly to set the Me.CustomerID property directly.  You'll have to go around the strong-typed property and set the field within the CurrentRow: Me.CurrentRow("CustomerID") = DBNull.Value.  The property will not accept null values...

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