473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Optimistic Concurrency in a web app

I am working on a system system that requires optimistic concurrency within
a web app. At first I thought this would be easy. We generate our own
entities and dal/service layer but I now see that working with controls like
a grid view pose some very complicated issues.

If I am using rowversion, when do I start the "clock"? When I first display
the label version of a field? when I display the data within a textbox for
edit or when I read the record for the 3rd time before updating new values
on the edit postback? And finally, where do I store rowversions for all of
these records in a web app since it doesn't look like they can be stored as
part of the gridview?

I am guessing that someone has wrestled with this alligator before. Any
suggestions or is this something that is so plagued with problems that it I
would just be better off not implementing it.

-Andy

Jan 31 '07 #1
4 1555
there are two approaches.

1) in the update compare every before value in the where clause (this is
how the asp.net datasource wizards work). so if any column was changed,
the update is rejected (row count == 0)

2) add a timestamp to each row, and compare on update.
-- bruce (sqlwork.com)

Andrew Robinson wrote:
I am working on a system system that requires optimistic concurrency
within a web app. At first I thought this would be easy. We generate our
own entities and dal/service layer but I now see that working with
controls like a grid view pose some very complicated issues.

If I am using rowversion, when do I start the "clock"? When I first
display the label version of a field? when I display the data within a
textbox for edit or when I read the record for the 3rd time before
updating new values on the edit postback? And finally, where do I store
rowversions for all of these records in a web app since it doesn't look
like they can be stored as part of the gridview?

I am guessing that someone has wrestled with this alligator before. Any
suggestions or is this something that is so plagued with problems that
it I would just be better off not implementing it.

-Andy
Feb 1 '07 #2
Bruce,

I am pretty familiar with what you pointed out. My question was more about
how to handle and more specifically when to store the timestamp value: from
the initial server postback, after an edit control is displayed to the user
or finally when the user posts back. There are three different options here.
And then, how do you handle saving the timestamp across those postbacks for
multiple rows in the case of a gridview.

Thanks,

"bruce barker" <no****@nospam.comwrote in message
news:eU****************@TK2MSFTNGP03.phx.gbl...
there are two approaches.

1) in the update compare every before value in the where clause (this is
how the asp.net datasource wizards work). so if any column was changed,
the update is rejected (row count == 0)

2) add a timestamp to each row, and compare on update.
-- bruce (sqlwork.com)

Andrew Robinson wrote:
>I am working on a system system that requires optimistic concurrency
within a web app. At first I thought this would be easy. We generate our
own entities and dal/service layer but I now see that working with
controls like a grid view pose some very complicated issues.

If I am using rowversion, when do I start the "clock"? When I first
display the label version of a field? when I display the data within a
textbox for edit or when I read the record for the 3rd time before
updating new values on the edit postback? And finally, where do I store
rowversions for all of these records in a web app since it doesn't look
like they can be stored as part of the gridview?

I am guessing that someone has wrestled with this alligator before. Any
suggestions or is this something that is so plagued with problems that it
I would just be better off not implementing it.

-Andy
Feb 1 '07 #3
Hello Andy,

As for the Timestamp column in SQL Server, it is mapped to SqlBinary(for
SqlDataTypes) and byte[](for .net type). And if you want to use such as
custom column and detect confliction, you may need to manually use
SqlCommand or SqlDataAdapter to perform the update statement execution,
here is a knowledge base article describe on this:

#HOW TO: Use a TimeStamp Column to Detect Update Collisions in ADO.NET with
Visual C# .NET
http://support.microsoft.com/kb/317095/en-us

For the ASP.NET 2.0 SqlDatasource based databound, it only support two
built-in concurrency detection approachs:

1. Compare all the columns in table(do not include any timestamp type
column since SqlDataSource can not handle this type for type mapping)

2. Override the old value anyway.

So if you still want to utlize the DataSource mode, I suggest you consider
use ObjectDatasource and use a custom Data Access class which expose the
"Select", "Update", "Delete" ... methods.

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Feb 1 '07 #4
Hello Andy,

Have you got any further progress on this? Does the concurrent control
suggestion in previous message helps some. As for the timestamp column
issue. Currently, we haven't direct means to handle it in the GridView or
such databound template control. If you do need some further thorough
workarounds or solution, I would suggest you contact CSS for further
assistance.

http://msdn.microsoft.com/subscripti...t/default.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Huddle | last post by:
Is there a way to turn off optimistic concurrency in ASP.NET when updating a record via the oleDBdataAdapter/oleDBcommandBuilder? If you use the Microsoft ASP.NET tools you can turn it off and...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
2
by: John | last post by:
In 'Data Adapter Configuration Wizard' for OleDbDataAdapter, there's a checkbox called 'Use optimistic concurrency' that allows to turn on/off the option. I don't use the wizard, I create...
2
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them...
0
by: russganz | last post by:
It seems to me there are real problems with the datagridview (along with the detailsview and form view) control when using optimistic concurrency with fields that can be null. Trying to use these...
6
by: shaanxxx | last post by:
I have global variable which is being shared between threads (problem is not connected with thread). Without using any mutex i have do some operation global variable in *consistent* way. ...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I was suddenly told to whip up a web project in ASP.Net 2.0. The last few weeks have been a crash course in new technology. I've done some 1.1 web work but it's been a while. The basics are...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
(If I'm overlooking anything, please let me know.) First, my only concern is updating single records in a Detailsview using an ObjectDataSource. The target table has a timestamp field. Assume ...
8
by: Roger.Noreply | last post by:
Hi, Sql-Server 2000, 2005. A report fetches a lot of rows using the "WITH (ROWLOCK)" syntax (the sql is generated on the fly by a tool and not easily changeable). SELECT col1, col2 FROM mytab...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.