Using transaction protection data in ADO.NET (1)

zhaozj2021-02-16  56

Use transaction in ADO.NET to protect your data integrity

Christa May 2004

Summary: When modifying data, transaction is a key feature of maintaining data integrity. Overview of transactions and their importance, learn how to use transaction protection data in your application. Content

Introduction

Profound analysis

Transaction in ADO.NET

Implement a business

Summary Introduction Most Enterprise Database provides a feature that provides a transaction in order to ensure data integrity during data modification. The integrity of maintenance data is to ensure that the organization's dependencies; after all, when you generate reports or do some data drivers Processing, you want to know that the data you operate is correct.

A successful transaction must be tested through "ACID", it must be this:

· Atomic - all express or perform correct in the transaction, or all of them roll. All operations represent or complete or fail, not the remaining parts, damage your data.

• Consistency - All data contact through transaction is logically consistent. For example, the number of inventories is in a consumed table, which has related order consumption inventory. Therefore, the inventory cannot be lost.

· Isolate - Transaction must have a number in the case where there is no interference or by other concurrent affairs interference. This prevents transaction to change data without authorization information. Most databases use the locked to ensure transaction Isolated.

· Persistence - The data modified by transaction is permanent and will continue until the system failed.

The classic example is submitting an order and order system - you have checked the customer's credibility level, create an order record, create an order entry, the consumption order entry is created in inventory, create a transport request, and so on. If you are in these steps or Multi-step failure, the rest will fail, you can end the data in an isolated, unreliable stock quantity, or other recording table. The correct use of transaction blocks this possible situation. This is for yours DBA, your company, the security of your work is good.

That is to say, remember that there is necessary to use business. Management transactions will increase the system overhead. Use transactions to increase the scope of locks (or other independent mechanisms, dependent databases), which will cause concurrency problems. Consider these situations The encapsulation is performed as an atomic unit as an atomic unit, considering the consequences generated in the enforcement environment, what happens when considering the partial completion.

The transaction can be implemented using the SQL variable of various native databases on the server side, or you can use ADO.NET to call in the app. This article uses ADO.NET data to provide objects to implement database transactions. I will start with transaction as start and see them How to interact with your database. Then look at how the .NET Framework provides how to help you implement and manage your transactions in the data read code, and have some usual scenes that have been used.

转载请注明原文地址:https://www.9cbs.com/read-26488.html

New Post(0)