Transferred from:Http://bbs.bccn.net/thread-310552-1-1.html
The main problem is that the character encoding of the Oracle client is inconsistent with that of the server.
Oracle Server character encoding: zhs16gbk
Oracle client character encoding: we8iso8859p1
There are three solutions:
(1) modify the client registry: locate nls_lang under the Oracle Installation and registration item and change the value to "simplified chinese_china.zhs16gbk
(2) by calling the _ putenv functionProgramChina siteCodeSettings:
Using system. runtime. interopservices;
...
[Dllimport ("msvcrt. dll")]
Private Static extern int _ putenv (string Str );
...
_ Putenv ("nls_lang = simplified chinese_china.zhs16gbk ");
// Database operations
_ Putenv ("nls_lang = american_amrica.we8iso8859p1 ");
(3) Use the C # built-in function to set Environment Variables
System. environment. setenvironmentvarible ("nls_lang", "simplified chinese_china.zhs16gbk ");
// Database operations
System. environment. setenvironmentvarible ("nls_lang", "american_amrica.we8iso8859p1 ");
Note that the second and third operations that use functions to set environment variables must take effect only outside the database operation.