Error creating connection to Oracle ODBC in Excel - 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.

Related

Getting "ORA-28000: the account is locked" while connecting from Python to Oracle

I have Python (3.8.3) and Oracle DB (11g Release 2 server) installed in my local system. Both of the software are working fine individually. I can run programs in python as well as I have tables created with data in Oracle DB which I am able to access through Oracle SQL Developer & SQL Plus.
But when I am trying to connect Oracle DB from python I am getting error as account locked. I have installed and executed import cx_Oracle successfully. But I am getting error when I am trying to execute below code.
1. Local initialization method -
connection = cx_Oracle.connect("oe/oracle#localhost:1522/orcl11g2")
2. Connecting through TNSNAMES.ORA -
connection = cx_Oracle.connect("oe", "oracle", "orcl11g2")
Error -
Traceback (most recent call last):
File "", line 1, in
cx_Oracle.DatabaseError: ORA-28000: the account is locked
My TNS Details -
File location - D:\app\Admin\product\11.2.0\dbhome_2\NETWORK\ADMIN
ORCL11G2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL11G2)
)
)
Please help me. Just let me know if you need to know anything more to guide me.
In SQL Developer or SQL*Plus, connect to the DB as a privileged user such as SYSTEM or SYS, e.g:
sqlplus system/yourpassword#localhost:1522/orcl11g2
Then run the SQL statement:
alter user oe account unlock;

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

ORA:12154 error in Excel 2007

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.

Resources