C # solutions to garbled Chinese characters written to Oracle

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.