Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 743927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:55:10+00:00 2026-05-14T08:55:10+00:00

Suppose, I am about to start a project using ASP.NET and SQL Server 2005.

  • 0

Suppose, I am about to start a project using ASP.NET and SQL Server 2005. I have to design the concurrency requirement for this application. I am planning to add a TimeStamp column in each table. While updating the tables I will check that the TimeStamp column is same, as it was selected.

Will this approach be suffice? Or is there any shortcomings for this approach under any circumstances?

Please advice.

Thanks

Lijo

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:55:11+00:00Added an answer on May 14, 2026 at 8:55 am

    First of all the way which you describe in your question is in my opinion the best way for ASP.NET application with MS SQL as a database. There is no locking in the database. It is perfect with permanently disconnected clients like web clients.

    How one can read from some answers, there is a misunderstanding in the terminology. We all mean using Microsoft SQL Server 2008 or higher to hold the database. If you open in the MS SQL Server 2008 documentation the topic “rowversion (Transact-SQL)” you will find following:

    “timestamp is the synonym for the
    rowversion data type and is subject to
    the behavior of data type synonym.” …
    “The timestamp syntax is deprecated.
    This feature will be removed in a
    future version of Microsoft SQL
    Server. Avoid using this feature in
    new development work, and plan to
    modify applications that currently use
    this feature.”

    So timestamp data type is the synonym for the rowversion data type for MS SQL. It holds 64-bit the counter which exists internally in every database and can be seen as @@DBTS. After a modification of one row in one table of the database, the counter will be incremented.

    As I read your question I read “TimeStamp” as a column name of the type rowversion data. I personally prefer the name RowUpdateTimeStamp. In AzManDB (see Microsoft Authorization Manager with the Store as DB) I could see such name. Sometimes were used also ChildUpdateTimeStamp to trace hierarchical RowUpdateTimeStamp structures (with respect of triggers).

    I implemented this approach in my last project and be very happy. Generally you do following:

    1. Add RowUpdateTimeStamp column to every table of you database with the type rowversion (it will be seen in the Microsoft SQL Management Studio as timestamp, which is the same).
    2. You should construct all you SQL SELECT Queries for sending results to the client so, that you send additional RowVersion value together with the main data. If you have a SELECT with JOINTs, you should send RowVersion of the maximum RowUpdateTimeStamp value from both tables like
    SELECT s.Id AS Id
        ,s.Name AS SoftwareName
        ,m.Name AS ManufacturerName
        ,CASE WHEN s.RowUpdateTimeStamp > m.RowUpdateTimeStamp
              THEN s.RowUpdateTimeStamp 
              ELSE m.RowUpdateTimeStamp 
         END AS RowUpdateTimeStamp 
    FROM dbo.Software AS s
        INNER JOIN dbo.Manufacturer AS m ON s.Manufacturer_Id=m.Id
    

    Or make a data casting like following

    SELECT s.Id AS Id
        ,s.Name AS SoftwareName
        ,m.Name AS ManufacturerName
        ,CASE WHEN s.RowUpdateTimeStamp > m.RowUpdateTimeStamp
              THEN CAST(s.RowUpdateTimeStamp AS bigint)
              ELSE CAST(m.RowUpdateTimeStamp AS bigint)
         END AS RowUpdateTimeStamp 
    FROM dbo.Software AS s
        INNER JOIN dbo.Manufacturer AS m ON s.Manufacturer_Id=m.Id
    

    to hold RowUpdateTimeStamp as bigint, which corresponds ulong data type of C#. If you makes OUTER JOINTs or JOINTs from many tables, the construct MAX(RowUpdateTimeStamp) from all tables will be seen a little more complex. Because MS SQL don’t support function like MAX(a,b,c,d,e) the corresponding construct could looks like following:

    (SELECT MAX(rv)
     FROM (SELECT table1.RowUpdateTimeStamp AS rv
          UNION ALL SELECT table2.RowUpdateTimeStamp
          UNION ALL SELECT table3.RowUpdateTimeStamp
          UNION ALL SELECT table4.RowUpdateTimeStamp
          UNION ALL SELECT table5.RowUpdateTimeStamp) AS maxrv) AS RowUpdateTimeStamp
    
    1. All disconnected clients (web clients) receive and hold not only some rows of data, but RowVersion (type ulong) of the data row.
    2. In one try to modify data from the disconnected client, you client should send the RowVersion corresponds to the original data to server. The spSoftwareUpdate stored procedure could look like
    CREATE PROCEDURE dbo.spSoftwareUpdate
        @Id int,
        @SoftwareName varchar(100),
        @originalRowUpdateTimeStamp bigint, -- used for optimistic concurrency mechanism
        @NewRowUpdateTimeStamp bigint OUTPUT
    AS
    BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.
        -- ExecuteNonQuery() returns -1, but it is not an error
        -- one should test @NewRowUpdateTimeStamp for DBNull
        SET NOCOUNT ON;
    
        UPDATE dbo.Software
        SET Name = @SoftwareName
        WHERE Id = @Id AND RowUpdateTimeStamp <= @originalRowUpdateTimeStamp
    
        SET @NewRowUpdateTimeStamp = (SELECT RowUpdateTimeStamp
                                      FROM dbo.Software
                                      WHERE (@@ROWCOUNT > 0) AND (Id = @Id));
    END
    

    Code of dbo.spSoftwareDelete stored procedure look like the same. If you don’t switch on NOCOUNT, you can produce DBConcurrencyException automatically generated in a lot on scenarios. Visual Studio gives you possibilities to use optimistic concurrency like “Use optimistic concurrency” checkbox in Advanced Options of the TableAdapter or DataAdapter.

    If you look at dbo.spSoftwareUpdate stored procedure carful you will find, that I use RowUpdateTimeStamp <= @originalRowUpdateTimeStamp in WHERE instead of RowUpdateTimeStamp = @originalRowUpdateTimeStamp. I do so because, the value of @originalRowUpdateTimeStamp which has the client typically are constructed as a MAX(RowUpdateTimeStamp) from more as one tables. So it can be that RowUpdateTimeStamp < @originalRowUpdateTimeStamp. Either you should use strict equality = and reproduce here the same complex JOIN statement as you used in SELECT statement or use <= construct like me and stay exact the same safe as before.

    By the way, one can construct very good value for ETag based on RowUpdateTimeStamp which can sent in HTTP header to the client together with data. With the ETag you can implement intelligent data caching on the client side.

    I can’t write whole code here, but you can find a lot of examples in Internet. I want only repeat one more time that in my opinion usage optimistic concurrency based on rowversion is the best way for the most of ASP.NET scenarios.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use current_page? if current_page? :controller => 'home', :action… May 16, 2026 at 2:01 pm
  • Editorial Team
    Editorial Team added an answer You could P/Invoke AnimateWindow() to get effects like this. Visit… May 16, 2026 at 2:01 pm
  • Editorial Team
    Editorial Team added an answer More specifically, User.Identity.Name returns in the format [Domain]\[User] If your… May 16, 2026 at 2:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm new to DDD and am thinking about using this design technique in my
I want to start a new project, there are currently 4 of us who
I have some misunderstanding about the gslice function. Definition from MSDN states: gslice defines
Looking for a best-practice advice: Let's suppose I have a Account object with limit
I have an ant task that contains javac task inside. It reports about error
suppose I have the following source table (called S): name gender code Bob 0
I am a little ashamed to say that I have never used an ORM;
In an N-Tier app you're supposed to have a business logic layer and a
I'm being forced/payed to work on a Legacy ColdFusion project (I'm an usual C#
Most of the time I have been programming little apps either for myself or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.