asp.net strong data type asp.net strong data type

Source: Internet
Author: User

The solution to the transaction problem in the strongly typed DataSet mentioned last time is also useful for general transaction solutions


The TransactionScope class provides a simple way in which you can mark a code block as participating in a transaction without interacting with the transaction itself. The transaction scope can automatically select and manage environmental transactions. Because it is easy to use and highly efficient, it is recommended that you use the TransactionScope class when developing a transactional application.

In addition, you do not have to explicitly register a resource with a transaction. Any system.transactions resource Manager, such as SQL Server 2005, can detect the existence of an environment transaction created by that scope and register automatically.
Before using, you should ensure that the MSDTC (Distributed Transaction coordination Processor) service is started:
The following figure:

So, when you do a strongly typed design, you can write code like this:
The steps are as follows:

1 Add (. net2.0) System.Transactions in the project reference
2 Adding a using System.Transactions in the head;
3 Add the following code fragment:


  using (System.Transactions.TransactionScope updatetransaction = New System.Transactions.TransactionScope ())
{
Ta. Insertname ("1456789", "456"), " 456 " );
Ta1. InsertName1 (
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.