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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
IT之家
IT之家
Google DeepMind News
Google DeepMind News
罗磊的独立博客
爱范儿
爱范儿
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
U
Unit 42
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
B
Blog
博客园 - 叶小钗
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - 小诈

[.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.