Using transactions to protect the integrity of data in Ado.net (1)

Source: Internet
Author: User
Tags implement
ado| data uses transactions in ado.net to protect the integrity of your data

Christa May 2004

Summary: When modifying data, transactions are a key feature of maintaining data integrity. Look at the business and its importance, and then learn how to use transaction protection data in your application.

Content

Introduced

Business Profiling

Transaction in Ado.net

Implementation transaction

Summarize

Introduced

Most enterprise databases provide a feature of transactions to ensure data integrity when data is modified. Maintain the integrity of the data to ensure that the organization depends on the quality of data; After all, when you generate a report or do some data-driven processing, you want to know that the data you're working on is correct.

A successful transaction must pass the "ACID" test, and it must be so:

· atomicity – All statements in the transaction are either executed correctly, or they are all rolled back. All operation sets represent or complete or fail, not the rest, damaging your data.

· Consistency – All data that is contacted by transactions is logically consistent. For example, the amount of inventory in a consumption table, where there are related orders to consume inventory. So inventory cannot be lost.

· Isolation – A transaction must affect the number of cases without interfering with other concurrent transactions or being interfered by other concurrent transactions. This prevents the transaction from changing the data without authorization information. Most databases use locks to guarantee the isolation of transactions.

· Persistence – The data modified by the transaction is permanent and lasts until the system fails.

The classic example is submitting orders and order systems – you've checked the customer's credit rating, created order records, created order entries, consumer order entries from inventory, create transport requests, and so on. If one or more of these steps fails, the rest will fail, and you can end the inconsistency in an isolated, unreliable inventory quantity, or other record form. The correct use of the transaction prevents this scenario from occurring. This is good for your DBA, your company, and the security of your work.

That is to say, remember to use a transaction if necessary. Managing transactions increases the overhead of the system. Using transactions also increases the scope of locks (or other independent mechanisms, dependent databases) in the system, which can cause concurrency problems. Consider that these situations are encapsulated into a transaction as an atomic unit, taking into account the consequences of the execution environment, and consider what happens when the part is completed.

Transactions can be implemented on the server side using SQL variables from various native databases, or they can be invoked in the application using Ado.net. This article uses ado.net data to provide objects to implement database transactions. I'll start with transactional profiling and see how they interact with your database. Then look at the usual scenarios in which the. Net Framework provides classes that help you implement and manage transactions in data-reading code.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.