.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));
            }

你可能感兴趣的:(.NET中访问Oracle数据库链接:ORA-02041: client database did not begin a transaction 问题的处理。)