Get the App
SLTechnology News&Howtos  ›  Development  › 

How to operate ADO database correctly

Shulou Source: shulou.com Published: 2022-06-02 08:06:42 09月19日 Update

This article mainly explains "how to operate the ADO database correctly". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to operate the ADO database correctly.

To complete the examples in this article, you need to make the following preparations:

Upgrade Visual Studio 2008 and .NET Framework 3.5 to SP1. Click to go to the upgrade address. It should also be possible to install the EXPRESS version of SQL SERVER that comes with SQL SERVER 2005 vs 2008. Download and attach the database: click to download DemoDbV2. Create a VB Console Application and give it an appropriate name (for example, Concurrency, etc.). Note that the target Framework should be set to version 3.5.

What is concurrency conflict

Let's take a look at an example related to withdrawal: at a certain time and a certain time in a certain year, Lao Wang in ADO database withdraws money from ATM A, while his son Xiao Wang withdraws money from ATM B at the same time (don't ask me why I am so clever ^ _ ^). They both withdraw money from the same account. So the following sequence of operations occurs:

An ATM asks the central database: how much money is left in this account?

B the cash machine asked the central database: how much money is there in this account? Central database answer A cash machine: 2W, central database answer B cash machine: 2W, then, ADO database Lao Wang said to A cash machine: I want to take out 1.5W. At the same time, Xiao Wang said to the B cash machine: I want to take out 1.8W.

Introduction to valid instructions for analyzing ADO.NET operation settings

Analyze the specific operation of ADO.NET database

Create a new project and select the ADO.NET Entity project for detailed section

An introduction to experts on ADO.NET Entity Framework object clearance

Illustration of the next generation of ADO.NET

A cash machine calculated, 2W-1.5W=0.5W > 0, so he spit out 1.5W cash to Lao Wang, and was ready to tell the central database that there was only 0.5W left. But just before it told the central database, the following happened:

The cash machine B calculates that 2W (at this time, it does not know that the balance has become 0.5W, because the cash machine A has not told the central database) minus 1.8W equals 0.2W greater than 0, so it spits 1.8W cash to Xiao Wang. Then, of course, the ADO database also notifies the central database.

The central database then received a message from ATM A, saying that the account still had 0.5W left, so the balance was refreshed to 0.5W. Then I received from the B cash machine that there was 0.2W left, so the balance was refreshed to 0.2W. Ha ha, so, Xiao Wang + Lao Wang's account has a total of 2W yuan, as a result, Lao Wang withdrew 1.5W yuan, Xiao Wang withdrew 1.8W yuan, but there was still 0.2W yuan left in the account.

This is a concurrency conflict in which an error occurs in the ADO database because two or more sides are operating on the same data at the same time. If the cash machine really handles concurrency in this way, then I won't write this article now-start the whole family to set their watches and agree to withdraw money at some point at the same time.

Thank you for reading, the above is the content of "how to operate the ADO database correctly". After the study of this article, I believe you have a deeper understanding of how to correctly operate the ADO database, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data database cash machine central Xiao Wang Lao Wang balance withdraw money at the same time study content that is I want article cash account account conflict preparation analysis Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MariaDB Docker Apple Shulou Technology