Oracle ORA-12154: TNS: Could not resolve service n

2019-01-23 05:50发布

I am a SQL Server user .

I am on a project that is using oracle (which I rarely use) I need to create an ODBC connection so I can access the some data via MS Access I have a application on my machine called oraHome90. It seems to allow a configuration of something called a listener in a “net configuration utility”, I think that a “Local Net Service Name Configuration” needs to also be done. The IT support gave me this information to set up the ODBC connection . I have tried every combination that I can think of. I can get past a test that successfully passes a test to “login“ to the oracle server database. When I try to create the ODBC connection I get the following error: ORA-12154: TNS: Could not resolve service name.

Assuming that I want to start from scratch and the following information is supposed to allow for me to connect to the database….. Any suggestions or comment ? Note: ultimately the project will have a website .ASP page query the data, but I have to first prove that I can see the data using the ODBC connection via MS Access

Service name: SERVICENAME
HOST = HOST.XYZi.com
User Id: MYUSERID
Password: MYPASSWORD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'Oracle Connection
Dim ocst
Dim oconn

ocst = "Provider=OraOLEDB.Oracle;" & _ 
        "Data Source=DATASOURCE;" & _ 
        "User ID=CHIJXL;" & _ 
        "Password=password;" 

set oconn = CreateObject("ADODB.Connection")

标签: oracle odbc tns
21条回答
萌系小妹纸
2楼-- · 2019-01-23 06:48

We resolved our issues by re-installing the Oracle Database Client. Somehow the installation wasn't successful on 1 of the workstations (even though there was no logging), however when comparing size/files/folders of the Oracle directory to a working client workstation, there was a significant amount of files that were missing. Once we performed a clean install, everything worked perfectly.

查看更多
爷、活的狠高调
3楼-- · 2019-01-23 06:50

If you have a 32bit DSN and a 64bit DSN with same names, Windows will automatically choose the 64bit one and If your application is 32bit it shows this error. Just watch out for that.

查看更多
女痞
4楼-- · 2019-01-23 06:50

I fixed this problem using this steps.

First of all, this error occured , if you didn't install same directory or drive.

But the answer is here.

  1. Login windows as a Adminstrator.
  2. Go to Control Panel.
  3. System Properties and click Enviroment
  4. Find the OS variable and change name as a "TNS_ADMIN"

    enter image description here

  5. And change the value as a "tnsnames's directory address" enter image description here

  6. Restart the system.

  7. Congrulations.
查看更多
登录 后发表回答