[ASP. NET password-breaking Reading Notes] ADO. Net Introduction

Source: Internet
Author: User

I. Creating an ASP. NET page transaction -- page transaction
Finally, you can create a transaction at the level of an ASP. NET page. you can enroll an ASP. NET page in a transaction by adding one of the following page directives to the ASP. NET page:

Disabled-transactions are disabled for the page. This is the default value.

Notsupported-indicates that the page does not execute within a transaction.

Supported-if a transaction already exists, the page will execute within the context of the transaction. However, it will not create a new transaction.

Required-if a transaction already exists, the page will execute within the context of the transaction. If a transaction does not exist, it will create a new one.

Requiresnew-creates a new transaction for each request.

Try
Cmdupdateaccounta. executenonquery ()
Cmdupdateaccountb. executenonquery ()

'Commit the transaction
Contextutil. setcomplete ()
Response. Write ("transaction successful! ")
Catch ex as exception
Contextutil. setabort ()
Response. Write ("transaction failed! ")
Finally
Conbank. Close ()

2. specifying a command behavior, which can obtain the first record and table structure information.
When you call the executereader () method of the command object you can pass an optional commandbehavior parameter. by supplying the commandbehavior parameter, you can gain greater control over how the executereader () method retrieves data from a database.

The commandbehavior enumeration has the following values:

Closeconnection-automatically closes an open database connection after the datareader is closed.

Keyinfo-retrieves column and primary key with the data. executes the query with the for browse clause.

Schemaonly-retrieves column and table schema information without retrieving data.

Sequentialaccess-enables access to database columns that contain a large amount of information.

Singleresult-optimizes the command to retrieve only a single result.

Singlerow-optimizes the command to retrieve only a single row. If multiple rows are returned, additional rows are discarded.

 

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.