ORA:12154 error in Excel 2007 - excel

I have an excel file which was developed by my predecessor and which uses external data connection to fetch data from Oracle.
I am trying to migrate this file to a new client PC and I am getting the following error while refreshing the data:
ora 12154 tns could not resolve the connect identifier specified
The connection is established via DSN and TNS reference. The system specifications are as:
OS: Windows 7 64 bit
Oracle Client: Oracle 10.2.0 32 bit.
DSN Created in the 32 bit odbcad32.exe
TNSNames.ora is as under:
ODS_BKUP = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.146.64.132)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ODSDB)
) )
I am able to do Test connection succesfully from the DSN. TNS ping also working for the server. But when I refresh the data in excel, I am getting the error.
Connection String Given in excel
DSN=MP_Prod;UID=ODS_MPMON;PWD=ODS_MPMON;DBQ=ODS_BKUP;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BAM=IfAllSuccessful;NUM
What am I missing?

same problem here and this is the solution:
https://community.spiceworks.com/topic/277836-excel-2010-ora-12154-tns-could-not-resolve-service-name
Hope this help you! =)
Ale.

Related

ORA-12560: TNS: protocol adapter error issue: Excel 64-bit/Windows 10 64-bit

I'm running a VBA script I used to use when connecting to Oracle database through Excel 32-bit but now I'm using Excel 64-bit.
VBA code:
Set cn1 = New ADODB.Connection
Set rs1 = New ADODB.Recordset
cn1.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=BR1P1;Uid=BR1USER;Pwd=myPass"
cn1.Open
rs1.Open Query, cn1
When I execute "cn1.open" I get this error:
"Run-time error'-214746... [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
Then I tried to solve adding a new data source:
ODBC Data Source Administrator (64-bit)> File DSN> click in Add...> from list I select: Oracle em OraClient11g_home1 ("Oracle em" means "Oracle for", my OS in in portuguese)> Next> browse to the file: "C:\Windows\System32\odbcad32.exe"> Next> Finish
Doing so system will give me the driver name: "Oracle em OracleClient11g_home1"
Afterwards it will prompt for Service Name, User Name and Password. I inform server Name according to my TNSNAMES.ORA
Back to VBA I changed the code according to the driver name:
cn1.ConnectionString = "Driver={Oracle em OracleClient11g_home1}"
Now when execute "cn1.Open" in VBA I receive this new error message:
"Run-time error'-214746... [Oracle][ODBC]ORA-12560: TNS:protocol adapter error"
My TNSNAMES.ORA file is like this:
BR1P1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.com)(PORT = 1575))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = BR1P1)))
Well I'm just stucked on this. Please I appreciate any help on this.
It's being a pain after I changed my MS Office to 64-bit version.
The Microsoft ODBC for Oracle exist only for 32-bit thus you cannot use it for 64-bit Excel.
If you like to use the 64-bit ODBC driver from Oracle then you must install it. Download the driver from 64-bit Oracle Data Access Components (ODAC) Downloads
The ConnectionString format of the Oracle ODBC Driver is different to the format of the Microsoft ODBC driver, see
Microsoft ODBC Driver - Connection String Format and Attributes
Oracle ODBC Driver - Format of the Connection String
or https://www.connectionstrings.com/oracle/ -> ODBC drivers
So, for Oracle your ConnectionString
Driver={Microsoft ODBC for Oracle};Server=BR1P1;Uid=BR1USER;Pwd=myPass
will be
Driver={Oracle em OracleClient11g_home1};DBQ=BR1P1;Uid=BR1USER;Pwd=myPass

MS Excel gets ORA-12560 protocol adapter error (SQLSetConnectAttr failed)

Using the Oracle client:
C:\temp> tnsping usrrprd
TNS Ping Utility for 32-bit Windows: Version 12.2.0.1.0 - Production on 06-JUL-2018 10:09:51
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
C:\Oracle12\product\12.2.0\client_1\network\admin\sqlnet.ora
Used LDAP adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = crs-rrdw-prd.tdbank.ca)(PORT = 1535)) (CONNECT_D
ATA = (SERVER = DEDICATED) (SERVICE_NAME = USRRPRD.tdbank.ca)))
I can access the server fine using sqlplus linqpad, sqldeveloper and even Visual Studio. Excel is stumping me, however. Using Microsoft Query and the Microsoft ODBC for Oracle Connect, I get:
Using the Data Connection Wizard, it connects and displays the tables and views. However, when I try to retrieve one, I get a different error:
Honestly, I'd take either approach, though since the table I want to see is large, Microsoft Query might be preferable.
How can I resolve these errors?

Cannot create direct connection to Oracle Server (Excel)

Hi I'm attempting to use some of the SQL code I've written in SQL developer through a direct database connection via Excel. Unfortunately the error message I receive whenever I try is:
"Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."
I've painstakingly installed the Oracle 64bit client on my PC, so that at least, should be working. Unfortunately I've spent the best part of two days looking up solutions on the internet with no success. Does anyone know how I can force Excel to use my 64bit client or avoid this error in another way?
Update:
I believe despite my best efforts the problem is somewhere within my TNSNAMES file since I can't connect using SQL Plus either. Here's a redacted version of my Connection string. The ommitted details are correct since they are the same as I'm using for SQL Developer. Am I missing something?
DB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
)
(CONNECT_DATA = (SID = SID1)(SERVER = DEDICATED)
)
)
DB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
)
(CONNECT_DATA = (SID = SID2)(SERVER = DEDICATED)
)
)
Obviously, it's something small in your machine settings or configuration.
I would suggest you will look at your machine's PATH environment variable. It may refer to an older version of Oracle Server or the Oracle Client Components.
Make sure you know what you are using to access Oracle from Excel, JDBC or ODBC?
It's always the little details which drive us crazy.
Did you see any of these answers?
SQL Server 2012 connectivity to Oracle
Getting MS Office 2013 (32 bit) Excel and Access to connect to Oracle database when both 32 and 64 clients are installed
and I found this link, too complicated to copy everything to the answer:
Connect To Oracle Via ODBC Driver
And you can try connecting to Oracle with ODBC using ODAC or Oracle client, download ODAC112030_x64.zip from Oracle's website. Here's a link on how to install it SETTING UP AN ORACLE ODBC DRIVER AND DATA SOURCE

Error creating connection to Oracle ODBC in Excel

I am trying to connect to Oracle ODBC for OraClient10g_home1 in System DSN.once done,i have tested the connection and it says connection successful.but when i try to import Oracle data from Excel's built-in function (Microsoft Query),it gives me the following error message.please let me know how to fix this issue.
Oracle Database Server - 32 Bit,Operating System - Windows 10(64-Bit),Excel Office 2010 (32-Bit)
in tnsnames.ora you should have an entry for database instance located in target server like :
Test=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST=target server)(PORT=1521))
)
(CONNECT_DATA =
(SID = orcl)
)
)
then tnsping Test in cmd should work fine. you will use this tns entry in your odbc.

Drivers to connect to an Oracle Database using VBA

I'm trying to connect to an Oracle Database from an Excel application and whithout a DNS. I found on a website that it's possible to use ADO, so this is why I tried to do. I'm new to this so I juste copied what I found on this website.
Here is my code so far :
Sub ADOtest()
Dim connection As New ADODB.connection
connection.ConnectionString = "UID = user1; PWD= my_pwd; DRIVER = {Microsoft ODBC for Oracle; Server= localhost; Database= orcl.my_domain;"
connection.Open
End sub
When I run this code, I get an error saying that the driver was not found.
The problem is that I have no idea of what I have to do with the driver (how to install it and configure it). Plus, I don't know which one I should use : I've read that there is a driver from Microsoft, another one from Oracle and also I've seen something about providers like msdaora.
The program will be used by many users, so I would like to choose the solution that is the lightest (not much to install on computers).
Thank you !
For COM based ADO (ADODB) you can use the OLE DB Providers.
One is from Oracle, called "Oracle Provider for OLE DB". You can download it from 32-bit Oracle Data Access Components (ODAC) and NuGet Downloads (assuming your Excel is 32-bit). The connection string would be
"Provider=OraOLEDB.Oracle;Data Source=orcl;User ID=myUsername;Password=myPassword"
The other one is from Microsoft. Please note, this provider is deprecated, you should not use it for new projects. Usually it should be available on your Windows. Be aware, like the provider from Oracle it also requires an Oracle Client to be installed on the PC! The connection string would be
"Provider=MSDAORA;Data Source=orcl;User ID=myUsername;Password=myPassword"
The data source is usually defined in tnsnames.ora file or at a LDAP server, for example:
orcl.my_domain =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
If you don't have such entry you can put everything into the connection string, e.g.
"Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));User ID=myUsername;Password=myPassword"
Perhaps you have to enclose the data source value by double-quotes ("), I am not sure.
So, in any case you would have to install an Oracle Client at all PC's.
Where is your database server hosted? In your question you say Server=localhost;, this would be quite unlikely, i.e. it is in contradiction to The program will be used by many users. I doubt everybody has an Oracle Database server installed on his local host.

Resources