.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
好像并不能解决问题,以下是解决的代码(针对只读情况,更新操作未作试验):
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";
 
            //command.Connection = oracleConnection1;
            //command.Transaction = oracleConnection1.BeginTransaction();
             oraDr = command.ExecuteReader(CommandBehavior.CloseConnection);
            command.Transaction.Commit();
            while (oraDr.Read() == true)
            {
                listBox1.Items.Add(oraDr.GetString(0));
            }
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页