I am using an Access db in order to retrieve records from Oracle 12 db. We've recently upgraded from Office 2016 to Office 365. Since that day I can no longer establish a connection via the class module.
Private Sub Class_Initialize()
Set mCnn = New ADODB.Connection
With mCnn
'.CursorLocation = adUseClient
.CursorLocation = adUseServer
.mode = adModeRead
.IsolationLevel = adXactIsolated
.CommandTimeout = 200
If PROMPT Then
.Properties("Prompt") = adPromptAlways ' if user must give password to connect
Else
.Properties("Prompt") = adPromptNever ' if there is no need of password
End If
End With
End Sub
Sub OpenConnection(s As String)
Dim msg As String, _
db As String, _
app_instance As String, _
connstring As String
On Error GoTo errHandler:
Dim usr As String
usr = Environ("UserName")
#If Win64 Then
'O365 64 bit drivers/Providers
' OracleConnection = "Provider=OraOLEDB.Oracle;Password=" & pw & ";User ID=" & uID & ";Data Source=" & HOST & ":" & portNo & "/" & sSID & ";Persist Security Info=True"
connstring = "Provider=OraOLEDB.Oracle;Password=" & pw & ";User ID=" & uid & ";Data Source=" & HostIPSSID & ";"
mCnn.ConnectionString = connstring
#Else
' for other non 64bits Windows versions
connstring = "Driver={Microsoft ODBC for Oracle};Server=" & server & ";UID=" & uid & ";PWD=" & pw
mCnn.ConnectionString = connstring
#End If
mCnn.Open
Exit Sub
end sub
.... however if I paste the code into a single sub it's not a problem - the connection string is 100% identical
Public Sub testttt()
Dim strSQL
Dim strUsername
Dim strPassword
Dim snpData
Dim dbMyDBConnection As ADODB.Connection
Dim connstring As String
Set dbMyDBConnection = CreateObject("ADODB.Connection")
strUsername = "dfagsdgasd"
strPassword = "asdgasdgd"
connstring = "Provider=OraOLEDB.Oracle;Password=" & strPassword & ";User ID=" & strUsername & ";Data Source=<SAME AS ABOVE>;Persist Security Info=True"
dbMyDBConnection.ConnectionString = connstring
dbMyDBConnection.Open
dbMyDBConnection.Close
Set snpData = Nothing
Set dbMyDBConnection = Nothing
End Sub
Any idea?