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

  • Home
  • SEARCH
  • 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 858539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:33:22+00:00 2026-05-15T08:33:22+00:00

Consider a web page having grid-view connected to SqlDataSource having all permission to insert

  • 0

Consider a web page having grid-view connected to SqlDataSource having all permission to insert update and delete.

Publish the web page.

This is all on one computer local

Now

  • opening website on browser A – pressing edit of grid-view
  • opening website on broswer B – pressing edit of grid-view.

Now I edit in both browsers and press update one by one fine no problem

The last update is the one retained.

But hypothetical situation:

  • what if there were two computers, or
  • what if I had two mouse pointers controlled by two independent mice

Computer has capability of running two apps at the same time

Both users get ready and press the update in the browsers at the same time

Even if you consider two different computers this is not possible but for this question

Consider it as possible

Update from two different sources to the same database same table same same row

At the same time, same second, same micro second no delay, both hit the database server at the same time.

What will happen?

In theory I have studied that database management software implement locks when writing no reading, no other writing, etc but does SQL Server 2005 Express implement locks in practical or is it assumed that situation like above will never occur?

If locks there please provide explanation or resource which would explain it keeping in view different scenarios of access

Thank you

edit:– I am not using control like sqldatasource so please when by providing statements to avoid bling update

its like– algo—

sqlconnection conn=new .....
sqlcommand
command text is "sql statement for updating values of a particular row"
conn.Open();  
cmd.ExecuteNonQuery();  
conn.close;

so as seen how can I define the check that before executenonquery that if the data is recently changed are you sure you want to proceed? or something

I am kind of confused here I think..
}

  • 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-15T08:33:23+00:00Added an answer on May 15, 2026 at 8:33 am

    SQL 2005 will enforce locks. Before a row can be updated the transaction must acquire an exclusive lock on it. Only 1 transaction can be granted this at a time so the other one will have to wait for that transaction to commit (2 phase locking) before being granted the lock that it needs for the update.

    The second write will “win” in that it will overwrite the first one. You can implement optimistic concurrency controls in the sqldatasource to detect that the row has changed and abort the second one rather than blindly overwriting the first edit.

    Edit

    Following clarification to the question. If you want to roll your own you could add a timestamp column to the table (In SQL Server 2005 this is updated automatically when a row is updated) and bring that back as a hidden dataitem in the gridview then in your UPDATE statement add a where clause UPDATE ... WHERE PrimaryKeyColumn=@PKValue AND TimeStampCol=@OriginalTimestampValue If no rows were affected (retrievable from ExecuteNonQuery – generally) then another transaction modified the row. This might be a bit more lightweight than the alternative used by the data source control where it passes back the original values of all columns and adds them into the WHERE clause with similar logic.

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

Sidebar

Related Questions

Consider two web pages with the following in their body respectively: <body> <script> document.writeln('<textarea></textarea>')
Consider a standard ASP.NET web application where the user types in some numeric data
Consider this problem: I have a program which should fetch (let's say) 100 records
In a web page I have a button when clicked it calls a JavaScript
Consider a PHP web application whose purpose is to accept user requests to start
Consider the following setup: A windows PC with a LAN interface and a WiFi
Consider the need to develop a lightweight desktop DB application on the Microsoft platforms.
Consider: List<String> someList = new ArrayList<>(); // add "monkey", "donkey", "skeleton key" to someList
Consider these two function definitions: void foo() { } void foo(void) { } Is
Consider the Oracle emp table. I'd like to get the employees with the top

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.