Jans的BLOG
Jans的BLOG

.NET中访问Oracle数据库链接:ORA-02041: client database did not begin a transaction 问题的处理。

.NET中访问Oracle数据库链接:ORA-02041: client database did not begin a transaction 问题的处理。
.NET中访问Oracle中带有DB_LINK时对象时,会抛出一下异常
ORA-02041: client database did not begin a transaction
意思是要设置一个事务,但是简单的BeginTransaction
好像并不能解决问题,以下是解决的代码
其中 DGIS_SP_MIS_WORKFLOW 中使用了一个数据库链接中的对象
(针对只读情况,更新操作未作试验):
 

OracleCommand command = new OracleCommand();

oracleConnection1.Open();

command.Connection = oracleConnection1;

command.Transaction = oracleConnection1.BeginTransaction(IsolationLevel.ReadCommitted);           

command.CommandText = "SET TRANSACTION READ ONLY";

OracleDataReader oraDr = command.ExecuteReader();

command.CommandText = "select * from DGIS_SP_MIS_WORKFLOW";

 

             

OracleDataAdapter oda = new OracleDataAdapter();

 

DataTable dtTable = new DataTable();

oda.SelectCommand = command;

oda.Fill(dtTable);

DBGrid1.DataSource = dtTable;

posted on 2005-12-17 20:50  Jans  阅读(1241)  评论(0编辑  收藏  举报