如何在.Net/C#中更改Oracle异常语言? [英] How to change Oracle Exceptions language in .Net/C#?
本文介绍了如何在.Net/C#中更改Oracle异常语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发连接到Oracle数据库的.Net应用程序.
I'm developping a .Net application that connects to an Oracle database.
在我的应用程序中,我不喜欢用法语抛出异常.
In my application, the exceptions are thrown in French which I don't like.
我正在使用以下代码来更改语言,但没有成功.
I'm using the following code to change the language but it's unsuccesful.
'Set the language to english
Dim Glob As OracleGlobalization = OracleGlobalization.GetThreadInfo
Glob.Language = "AMERICAN"
OracleGlobalization.SetThreadInfo(Glob)
在此代码之后,仍然会以法语抛出异常.
After this code the exceptions are still thrown in French.
请问有人知道如何更改例外语言吗?
Does anyone know how to change the Exceptions Language please ?
谢谢.
推荐答案
您应执行ALTER SESSION命令.也许您的API拥有它的Facade方法,但这是无处不在的一种终极方式.参见示例:
You should execute ALTER SESSION command. Maybe your API has facade methods for it, but it's an ultimate way for everywhere and always. See example:
SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 11 16:01:02 2014
SQL> conn test/test@soft12c1
Connected.
SQL> alter session set nls_language=french;
Session altered.
SQL> select 1/0 from dual;
ERROR at line 1:
ORA-01476: le diviseur est щgal р zщro
SQL> alter session set nls_language=american;
Session altered.
SQL> select 1/0 from dual;
ERROR at line 1:
ORA-01476: divisor is equal to zero
这篇关于如何在.Net/C#中更改Oracle异常语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文