Connecting C# app with Oracle 10g: ORA-12154: TNS:could not resolve the connect identifier specified

微笑、不失礼 提交于 2019-12-06 00:18:29

Start the Visual Studio, open View menu + Server Explorer.

  1. Right mouse click on Data Connection + Add Connection + Select Oracle Database
  2. server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.

From properties windows you can obtain connection String and it should be look a like:

Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True

Oracle is just stating that it can't find the database.

If you're running a local Express Edition database, you should be able to just use XE as an instance name, and everything should already be set up, otherwise you can most easily add it to tnsnames.ora.

To find the correct tnsnames.ora to change, you can try (from the command prompt)

tnsping ORCL

That will tell you which files Oracle is using to try to find the database. If tnsping is an unknown command, you may have to search for it and go to the correct place before running it.

One you found the correct tnsnames.ora, you need to add the instance ORCL to it. There should be an existing file with examples, the syntax of that file is too complex to answer here, if you need help, Oracle has quite extensive documentation.

This is a very common oracle error. Simply put, it means that you have named the database you wish to be connected to and Oracle doesn’t know who the heck you’re talking about. I suggest 6 Steps to fix ORA-12154:

  1. Check instance name has been entered correctly in tnsnames.ora.
  2. There should be no control characters at the end of the instance or database name.
  3. All paranthesis around the TNS entry should be properly terminated
  4. Domain name entry in sqlnet.ora should not be conflicting with full database name.
  5. If problem still persists, try to re-create TNS entry in tnsnames.ora.
  6. At last you may add new entries using the SQL*Net Easy configuration utility.

More informations on oracle site or here : http://turfybot.free.fr/oracle/11g/errors/ORA-12154.html

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