In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to solve the problem of garbled code in C# connection ORACLE". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to solve the garbled problem of C# connection ORACLE"!
Catalogue
Method one
Method two
Method three
Method 4
I have done java project before, and I am easy to connect to all kinds of databases. Recently, when I came into contact with a project of c #, it was also easy to connect to SqlServer database, but when I encountered oracle database, I withered, so I searched for a lot of information, some used oracle.datamanager.dataaccess, some used System.Data.OracleClient.OracleConnection, and some connected to System.Data.OleDb.OdbcConnection, but the first two methods were tried, and the code was still so garbled, so I tried the last one:
Method one
Connection string:
"Provider=oraoledb.oracle;Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.20.10.10) (PORT = 1521)) (CONNECT_DATA = (SID = orcl); User Id=user;Password=user"
Error: unregistered data provider!
So continue to search, the Internet said that the need to install oracle-related connection components, which is very troublesome, it is impossible to install this component on all machines
So continue to find a solution, and finally found that the following connection is OK, that is, when using System.Data.OracleClient.OracleConnection, no longer prompt the registration program and so on, the problem is finally solved, the query results are not garbled!
Connection string:
"Provider=MSDAORA.1;Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST =
10.20.10.10
) (PORT = 1521)) (CONNECT_DATA = (SID = orcl); User Id=lswen;Password=1169 "
Note: Provider=MSDAORA.1;, not Provider=oraoledb.oracle
Method two
1. Open the registry: start-run-regedit
HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/KEY_OraDb11g_home1/OLEDB
Click the right mouse button on the right-- New-- string value-- name changed to: NLS_LANG value set to: SIMPLIFIED CHINESE_CHINA.ZHS16GBK
two。 My computer-Properties-Advanced system Settings-Environment variables-Click New under the system variables-variable name: NLS_LANG variable value: SIMPLIFIED CHINESE_CHINA.ZHS16GBK
Method three
The solution given by classmate make1828
1: first query the character encoding of oralce: select userenv ('language') from dual
2: set the NLS_LANG variable in the environment variable:
3: configure the connection string:
Provider=OraOLEDB.Oracle;User ID=***;Password=***;Data Source= (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP) (HOST = * *) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL)
4: install Oracle client: (you can search and download it on the Internet)
5: download a PLSQL tool if you need it
You can download the https://www.yisu.com/softs/664139.html.
Method 4
Recently, when I used the program to read the data in the oracle database, I found that the Chinese characters were all garbled. So I launched a series of methods to finally solve this problem.
Working environment: server windows 2003 + oracle.
Server character set SIMPLIFIED CHINESE_CHINA.WE8DEC.
Programming environment VS2005,C#,PLSQL.
Option 1:
Use the System.Data.OracleClient.OracleConnection class to access the database.
Connection string:
"Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 172.20.0.5) (PORT = 1521)) (CONNECT_DATA = (SID = DEV); User Id=lswen;Password=1169"
Change the local character set to the same as the server.
Open the registry regdit:
Change NLS_LANG to: SIMPLIFIED CHINESE_CHINA.WE8DEC in HKEY_LOCAL_MACHINE\ SOFTWARE\ ORACLE\ HOMEO.
This method is like a nightmare and can not be solved at all. Many people have published this method on the Internet. The answer is one-sided, if the server's character set is: ZHS16GBK, then this method can be solved. The character set WE8DEC itself contains not many Chinese characters. The reason why it allows storing Chinese characters is that it divides a Chinese character into two bytes, and the clients of other Chinese character sets can not be directly restored to one Chinese character. So you have to keep the client consistent with the server-I don't know if I understand what I see online.
Plan one failed.
Option 2:
Use the System.Data.OleDb.OdbcConnection class to access the database.
Connection string:
"Provider=MSDAORA.1;Data Source= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 172.20.0.5) (PORT = 1521)) (CONNECT_DATA = (SID = DEV); User Id=lswen;Password=1169"
Change the local character set to the same as the server in the same way as scenario 1.
Now the problem is finally solved.
Emphasize that the connection string cannot use Provider=oraoledb.oracle because of the use of Provider=MSDAORA.1;
Plan two worked.
Summary:
This problem exists in both WE8DEC and some other Western European character sets, which should be solved with the second solution.
At this point, I believe you have a deeper understanding of "how to solve the garbled problem of C# connection ORACLE". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.