Hi All.
I want to use Excel VBA to connect to oracle Database to get Data.
Here is the code
Const PMCalculate = "192.168.2.IP" '"ServerName" ' Server hosting the Oracle db
Const DBNAME = "NMS" '"DatabaseName"
Const ORACLE_USER_NAME$ = "user"
Const ORACLE_PASSWORD$ = "pass"
Const port = "1521"
Sub ConnectTOOracle()
Dim oRs As ADODB.Recordset
Dim oCon As ADODB.Connection
Set oCon = New ADODB.Connection
Dim mtxData As Variant
Dim strConOracle As String
strConOracle = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) "
strConOracle = strConOracle & "(HOST=" & PMCalculate & ")(PORT=" & port & "))(CONNECT_DATA=(SERVICE_NAME=" & DBNAME
strConOracle = strConOracle & "))); uid=" & ORACLE_USER_NAME & " ;pwd=" & ORACLE_PASSWORD & ";"
oCon.Open strConOracle
'Cleanup in the end
Set oRs = Nothing
Set oConOracle = Nothing
End Sub
And the error
1.jpg
Bookmarks