SET_NLS fails over Oracle ODP.net

帅比萌擦擦* 提交于 2019-12-11 08:05:53

问题


I try to execute the follwing statement from a c# program with ODP.NET:

string sql = "BEGIN dbms_session.set_nls('NLS_NUMERIC_CHARACTERS','''.,'''); END;";
        using (OracleConnection connection = new OracleConnection("Data Source=db;User Id=a;Password=b"))
        {
            connection.Open();
            using (OracleCommand command = new OracleCommand(sql, connection))
            {
                command.ExecuteNonQuery();
            }
            connection.Close();
        }

I retrieve the follwing error message:

ORA-02074: cannot SET NLS in a distributed transaction

I don't use any transaction in my code. Is the OracleConnection an implicit distributed transaction? If I add enlist=false to the connection string it works. But I don't know why.


回答1:


I don't know much about C#, but are you sure you need the connection.Open() and connection.Close() statements? I would assume that the using statement takes care of that.




回答2:


I don't need distributed transactions in my environment, so I just solved this by appending enlist=false to my connection string. Hope it may be useful to someone.



来源:https://stackoverflow.com/questions/11221971/set-nls-fails-over-oracle-odp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!