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