I'm trying to connect my Excel to Oracle with this connection string in VBA:
And I get error msg below:
Run-time error '-2147467259 (800004005)': ORA-12154: TNS:could not resolve the connect identifier specified
Using: - Excel 2016 64-bit - Windows 10 64 bit - Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit - PL/SQL Release 12.1.0.2.0 - CORE 12.1.0.2.0 - TNS for Linux: Version 12.1.0.2.0 - NLSRTL Version 12.1.0.2.0
Excel 64-bit & oracle is provided by company, hope can settle it without change excel to 32-bit. Any help will be appreciated. I actually already tried to settle it for two days and see no hope at all. Thanks for your time.
Not sure if is the driver i used is 32-bit? Microsoft ODBC for Oracle, MSORCL32.DLL Oracle in Client_11_Std_x86_1, SQORA32.DLL
Dim cnPubs As ADODB.connection
Set cnPubs = New ADODB.connection
Dim strConn As String
With cnPubs
strConn = "Provider=OraOLEDB.Oracle;" & _
"Data Source=" & sSource & ";" & _
"User ID=" & sAC & ";Password=" & sPW & ";"
.Open strConn
.CommandTimeout = 0
End With
sSource
. The drivers should be fine as you get an Oracle error, i.e. the DLL's have been loaded successfully. Do you use antnsnames.ora
file? Where is it located? Did you setTNS_ADMIN
variable? – Wernfried Domscheittnsadmin.ora
file will work. – Wernfried Domscheit(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.0)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORA12)))
. These aliases are defined in yourtnsadmin.ora
file. When you say is was working with msdaora providers then it should be fine. Just point value ofTNS_ADMIN
variable to the location of yourtnsadmin.ora
file. – Wernfried Domscheit