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 8702081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:33:41+00:00 2026-06-13T02:33:41+00:00

I have an automation project having a remote database (MsSql) and multiple windows/web clients.

  • 0

I have an automation project having a remote database (MsSql) and multiple windows/web clients. Client applications check and select a suitable row on a table and mark it as reserved for operating on that row.

  1. How can I easily get value and update a selected row before another client selects same row? What options do I have for that?
  2. Can I use TransactionScope for that purpose if I want to do more than one select-update statement (for different tables) inside transaction block?

EDIT:
Let’s imagine a cinema ticket system (mine is a little bit more complicated). The user selects a seat and buys ticket. I want to reserve the seat to this user for two minutes to give enough time for buying. After two minutes it will be also available to others. Before updating the row I run a select query to find the first empty seat. My question is about a little time between a select and update statement of same user. I want to prevent: User1’s select statement runs and at that time User2 runs same select before User1 reserves the seat.

  • 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-06-13T02:33:42+00:00Added an answer on June 13, 2026 at 2:33 am

    Since you want user input between locking and performing actual action, then

    update top (1) seats
    set time_locked = getdate(), user_locked = <the site user>
    output inserted.seat_id, inserted.time_locked, inserted.user_locked
    where <your conditions> and time_locked is null
    

    In this case you don’t start a transaction before doing this, because you want to commit the change immediately. You may open a transation later, as soon as you lock a row, or at an even later point.

    If you do that from a transaction, then the other processes will wait until you commit that transaction, so you will not get any concurrency. What you will then see is, one process working, all others waiting.

    When you later come back to the locked row, you verify that time_locked is still non-null, and the user who locked is the same user:

    update seats
    set totally_taken = 1
    where
      seat_id = <remembered seat id>
      and time_locked = <remembered time_locked>
      and user_locked = <remembered user_locked>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MFC/C++ project that uses the ActiveX Document (Automation) approach for opening
I am having a weird issue with my profiles. For my project, i have
I have this Caliburn.Micro sample project I'm putting together and I am having trouble
VSTO 4.0 / Office 2007 In an Excel document-level automation project, I have a
I am about to start work on a UI automation project for a client
I'm working on an automation project for my employer. We have a pool for
I have created a project in Eclipse for Selenium automation using testNG framework. I
So I have a project where there is some automatic initialization going on through
I have an automation system and I would like to record user logins and
I have the following automation code: lPrintSetup := fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup); lPrintSetup.Printer := 'MyPrinter'; lPrintSetup.DoNotSetAsSysDefault :=

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.