惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - 小诈

[.net]正则表达式整理 今日所思 伟大的意大利夺冠了!疯狂庆祝! word add-in 卸载时如何清除自定义的按钮和菜单 制作包含.net framework的安装包 解决不能上网的问题(Wincock绑架) [ASP.NET揭密读书笔记]额外的控件和资源 [ASP.NET揭密读书笔记]应用程序跟踪和监视 [ASP.NET揭密读书笔记]用户自定义控件 [ASP.NET揭密读书笔记]连接池 安装Ubuntu 痛苦的胃镜检查 [转载]微软好员工的十个标准 新年新气象,恭喜发财 WEB中服务器端Table的行集中要注意ViewState 2005年年终总结 招聘.NET高级软件工程师 DataTable.Select方法的性能问题 [转贴]Visual Studio 2005常用插件搜罗
[ASP.NET揭密读书笔记]ADO.NET介绍
小诈 · 2006-06-26 · via 博客园 - 小诈

一、Creating an ASP.NET 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()

二、Specifying a Command Behavior,可以获取第一个记录,表的结构信息等
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.