With setup from text below I successfully connected and retrieve data from DB. One time, while macro was executing, my PC (windows 10) lost the power and from that moment on I'm receiving the error every time I tried to connect to DB (only while I'm trying to connect via VBA) with following message:
Run-time error '-2147467259 (80004005)':
[Microsoft][ODBC driver for Oracle][Oracle]Error while trying to retrieve text for error ORA-01019
Error that I received is from the line with command "cn.Open (strConnection)"
I have installed ODAC 12c 32bit because I have Excel 32bit.
I think that this error is active because of info from some register which is locked after PC lost the power while retrieving data but I can't find it.
Any help or hint will be precious to me.
Thanks in advance
Dim strConneciton As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
strConneciton = "Driver={Microsoft ODBC for Oracle};" & _
"CONNECTSTRING=(DESCRIPTION=" & _
"(ADDRESS=(PROTOCOL=TCP)" & _
"(HOST=xxx.xxxx.xxx)(PORT=1521)" & _
"(CONNECT_DATA=(SERVICE_NAME=xxxxx)));user id=user1;password=1234;")
cn.Open (strConneciton)
If cn.State = adStateOpen Then
cn.Close
MsgBox "Completed!"
Else
MsgBox "Connection failed!"
End If
Thanks for answers.
I added those locations to the PATH variable, but the problem is the same.
With change of a driver (Oracle in OraClient12Home1_32bit - which is correct name in ODBC Data Source Administrator (32bit)), I've got the following error:
TNS protocol adapter error.
I am able to connect from sqlplus to db, but the problem is when I tried to connect via VBA.
@Tim, thanks for that hint, but that is not the problem here, I've checked that before.
Finally I finished this with new Connection string as you can see below:
strConnection = "Provider=OraOLEDB.Oracle;Data Source=xxx.xxxx.xxx:1521/xxxxx;User ID=user1;Password=1234;"
Thanks again.