Use ADO. Net to configure SQL Server Transaction Processing

Source: Internet
Author: User
Tags savepoint

This prevents non-repetitive data reading (nonrepeatable reads );

Serialisable: locks the range in dataset to prevent other users from updating data or inserting rows in the database before the transaction processing ends;

Isolationlevel defines the lock record level, but this concept is not covered in this article. The object sqltransaction also provides a similar method. You can use the following methods to process transactions:

Commit: submits database transactions;

Rollback: never final state (pending state) Roll Back transaction processing. Once a transaction is committed, this operation cannot be performed;

Save: You can create a savepoint in a transaction to reverse a part of the transaction and specify the savepoint name.

The following C # example combines these parts.

This simple ConsoleProgramFollow these steps to insert two rows into the table of the northwind database:

Call the begintransaction method of the connection object to mark the start position of transaction processing. The begintransaction method returns a coordinate (Reference) for the transaction processing, which is specified to the command object used by the transaction processing.

Specify the transaction object to the transaction attribute of the command to be executed. If a command is executed on the connection in the active transaction and the transaction object is not specified to the transaction attribute of the command, an exception is thrown.

Call the commit method of the transaction object to end transaction processing, or call the rollback method to cancel transaction processing.

Equivalent VB. NETCodeSimilar.

Transaction Processing ends
Although this is a simple example, it fully shows how simple it is to use transactions in. NET applications. Remember that transaction processing is only necessary to process a group of commands.

Related Article

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.