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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:51:17+00:00 2026-05-13T21:51:17+00:00

My application is storing some data in SQL Table called Transactions. Users are able

  • 0

My application is storing some data in SQL Table called Transactions. Users are able to sell something from Client1 to Client2 and then Client2 has it. I am storing it in a table the following way:

Client 1 | Buy  | Something | Price  | External |
Client 1 | Sell | Something | Price2 | Client 2 |
Client 2 | Buy  | Something | Price2 | Client 1 |

First Client1 bought it (brought it in or just has it for all it matters). Then he sells it to another client.

And all that is fine, it works but my application has a short time when it doesn’t check if Client 1 still has what it claims to have (when data is loaded into gui).
So if 2 users would make run for it it’s possible that product from Client1 could be sold multiple times. Most likely it won’t happen since my users tend to share their work on what they are doing but there’s always BUT…

How to prevent this? Would simple select query check just before insert transaction be sufficient or should this be done differently? (I can imagine situation when multiple people make run for it and some would succeed). How is this handled in real world situations on heavy systems? Like when you pick money from one bank account with 2 cards from 2 different CashMachines (although i believe they would just let balance go under 0 in this case even if it wouldn’t be allowed).

So what options do I have? What is your take on this?

  • 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-13T21:51:17+00:00Added an answer on May 13, 2026 at 9:51 pm

    I assume this is not a real inventory tracking system, where the database merely record real world events, but instead is a some virtual auction or market place sort of application, where ‘reality’ is whatever the application believe it is.

    If you only keep history, you’ll never have the current state. W/o a current state, you can’t make efficient correctness decisions. So keep a current state. Have a table of items and their current owner. The problem you ask then become a simple problem of ‘How to I prevent a lost update?’ or ‘How do I prevent a blind write’? (ie. a write-write conflict) and the answer is well known in database application: use optimistic concurrency control.

    For a detailed discussion of how to use Optimistic Concurrency with C# and SQL, see Optimistic Concurrency (ADO.NET).

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll need a custom type converter: Mapper.CreateMap<Student, int>().ConvertUsing(src => src.Id); May 17, 2026 at 12:24 am
  • Editorial Team
    Editorial Team added an answer You can look at the source of those GTK functions… May 17, 2026 at 12:24 am
  • Editorial Team
    Editorial Team added an answer The reason your code doesn't work is because you are… May 17, 2026 at 12:24 am

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

In C# ASP.NET MVC application I use Link to SQL to provide data for
This is my first MVC/Linq to SQL Application. I'm using the out of the
I'm building an offline C# application that will import data off spread sheets and
(This post is soliciting personal experiences about storing XML; please share what you know.
In a C++ application that can use just about any relational database, what would
I am working in ASP.NET 3.5 MVC application. We have a functionality where we
I have a database running on MS SQL Server 2005 and an ASP.NET 3.5
I'm currently in the middle of a reasonably large question / answer based application
I'm not the first to have these issues, and will list some reference posts
Hei guys i have this JQuery Ajax call from my view and it looks

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.