ASP. NET 2.0 technical insider (Reading Note 2)

Source: Internet
Author: User

Use transactions
The isolation level can be modified at any time and valid before the display changes. If the isolation level is modified during a transaction, the server should apply a new blocking level to all the remaining statements.
Terminate a transaction explicitly by using the commit or rollback method.
Transaction recovery transactionscope object
Implement Distributed Transaction Processing

Bool Cancommit =   True ;

Using (Transactionscope TS =   New System. Transactions. transactionscope ())
{
// **************************************** *****************
// Update northwind on SQL Server 2000
Using (Sqlconnection Conn =   New Sqlconnection (connstring ))
{
Sqlcommand cmd =   New Sqlcommand (updatecmd, Conn );
Cmd. Connection. open ();
Try
{
Cmd. executenonquery ();

}
Catch (Sqlexception ex)
{
// Error Handling Code goes here
Lblmessage. Text + = Ex. message;
Cancommit & =   False ;
}
}

// **************************************** *****************
// Update numbers on SQL Server 2005
Using (Sqlconnection Conn =   New Sqlconnection (connstring05 ))
{
// Sqlcommand cmd = new sqlcommand (raiseerror, Conn );
Sqlcommand cmd =   New Sqlcommand (insertcmd, Conn );
Cmd. Connection. open ();
Try
{
Cmd. executenonquery ();
}
Catch (Sqlexception ex)
{
// Error Handling Code goes here
Lblmessage. Text + = Ex. message;
Cancommit & =   False ;
}

}

// Must call to complete; otherwise abort
If (Cancommit)
TS. Complete ();
}
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.