system.Data.OracleClient.dll [英] system.Data.OracleClient.dll

查看:120
本文介绍了system.Data.OracleClient.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
谁能解释并举例说明oracleConnection.EnlistTransaction方法?

我搜索了google,但没有人以一种可以理解的方式进行解释.

hi
can any one explain and give some example to oracleConnection.EnlistTransaction Method?

I searched google , but no one explained in a understandable manner.

推荐答案

加入交易意味着相互进行两个或多个交易.调用此方法将立即注册到由所提供的事务参数指定的分布式事务的连接.如果OracleConnection仍与先前的EnlistTransaction方法调用尚未完成的分布式事务关联,则调用此方法将引发异常.通常,为使分布式事务登记成功,在调用Open方法之前,必须将登记连接字符串属性设置为true或动态.如果连接在事务上下文中,则将enlist连接字符串属性设置为true会在调用Open方法时隐式地注册连接.将其设置为动态可以在调用EnlistTransaction或EnlistDistributedTransaction方法时动态地使连接加入分布式事务中.仅当连接永远不会参与分布式事务时,才应将enlist属性设置为false.

Enlist transaction means engaging two or more transactions with each other. Invocation of this method immediately enlists the connection to a distributed transaction that is specified by the provided transaction parameter. If OracleConnection is still associated with a distributed transaction that has not completed from a previous EnlistTransaction method invocation, calling this method will cause an exception to be thrown. In general, for distributed transaction enlistments to succeed, the enlist connection string attribute must be set to either true or dynamic before invoking the Open method. Setting the enlist connection string attribute to true will implicitly enlist the connection when the Open method is called, if the connection is within a transaction context. Setting it to dynamic allows the connection to dynamically enlist in distributed transactions when an EnlistTransaction or EnlistDistributedTransaction method is called. The enlist attribute should be set to false only if the connection will never enlist in a distributed transaction.

OracleCommand1.Connection=OracleConnection1; 
using (TransactionScope transScope = new TransactionScope()) { 
 OracleConnection1.Open(); 
 OracleCommand1.ExecuteNonQuery(); 
 transScope.Complete(); 
} 
OracleConnection1.Close(); 
 
- or - 
 
OracleCommand1.Connection=OracleConnection1; 
OracleConnection1.Open(); 
using (TransactionScope transScope = new TransactionScope()) { 
 OracleConnection1.EnlistTransaction(Transaction.Current); 
 OracleCommand1.ExecuteNonQuery(); 
 transScope.Complete(); 
} 
OracleConnection1.Close(); 
 
- or - 
 
CommittableTransaction cmtTx = new CommittableTransaction(); 
OracleConnection1.Open(); 
OracleConnection1.EnlistTransaction(cmtTx); 
OracleCommand1.ExecuteNonQuery(); 
OracleConnection1.Close();


在我看来,该知识库很好地说明了示例:
It looks to me that this knowledgebase explain nicely with example: Oracle ADO.NET 2.0 Features[^]
Have a look at it.


这篇关于system.Data.OracleClient.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆