所有
我正在尝试通过VBA通过云连接到oracle数据库。以下是我的代码。当我在变量" strConOracle"之后调试打印我的VBA时设置后,变量打印如下
strConOracle
Provider = OraOLEDB.Oracle; Dat enter code here
a Source = coloplast-stg-rdb.cloud.modeln.com:4004:CPHSTG;用户ID = jpathil;密码= Jean1121;
这似乎没问题,因为我通过SQL Dev连接的数据库凭据位于
之下用户名:jpathil 密码:Jean1121 主机名:coloplast-stg-rdb.cloud.modeln.com 港口:4004 服务名称:CPHSTG
下面的代码有什么问题?它在最后一行失败" oConOracle.Open strConOracle"
Sub QueryConstructOracle()
Dim QueryVar As String
Dim db As Database
Dim rs As Recordset
HOST$ = Sheets("Connection Setup").Range("Server")
DBNAME$ = Sheets("Connection Setup").Range("Database")
ORACLE_USER_NAME$ = Sheets("Connection Setup").Range("User")
ORACLE_PASSWORD$ = Sheets("Connection Setup").Range("Password")
ORACLE_PORT$ = Sheets("Connection Setup").Range("Port")
sourcedb = Sheets("Connection Setup").Range("DataSource")
Dim strConOracle As String
Dim oConOracle, oRsOracle
Dim strSQL As String
On Error GoTo errHandler
Application.Calculation = xlManual
Application.ScreenUpdating = False
' Set connections
strConOracle = "Provider=OraOLEDB.Oracle;Data Source=" & sourcedb & ":" & ORACLE_PORT$ & ":" & DBNAME$ & "; User ID=" & ORACLE_USER_NAME$ & ";Password=" & ORACLE_PASSWORD$ & ";"
Set oConOracle = CreateObject("ADODB.Connection")
oConOracle.Open strConOracle
End Sub