更新时间:2022-11-05 20:01:56
我认为数据源= xxxxxxx.db.yyyy.com:端口
是问题。您应该提供文件 tnsnames.ora
中定义的TNS别名,而不是ServerName.Domain:Port。
我不知道OLEDB提供商是否支持Easy Connect命名方法。您在 sqlnet.ora
文件中指定像 NAMES.DIRECTORY_PATH =(tnsnames,ezconnect)
I'm using this connection string pattern with ADODB
Set oConn = New ADODB.Connection
oConn.ConnectionString = "User ID=USERNAME;Password=PW;Data Source=xxxxxxx.db.yyyy.com:port;Provider=OraOLEDB.Oracle; "
oConn.ConnectionTimeout = 30
oConn.Open
rs.CursorType = adOpenForwardOnly
and when I open the connection I'll get a run time error
ORA-12504: TNS:listener wa not given the SERVICE_NAME in CONNECT_DATA
I have also tried using this connection string
"ODBC;DRIVER={Oracle in OraClient11g_home2};" & _
"DBQ=" & inputHost & ";UID=" & inputUser & ";PWD=" & inputPassword & ";" & _
"HOST=" & inputHost & ";PORT=1521;DB=" & inputHost & ";" & _
"DefaultIsolationLevel=READUNCOMMITTED"
and I get the run time error
[Microsoft][ODBC Driver Manager] Data source name not found an no default driver specified
I think Data Source=xxxxxxx.db.yyyy.com:port
is the problem. You should provide the TNS alias as defined in file tnsnames.ora
instead of "ServerName.Domain:Port".
I do not know if OLEDB provider supports Easy Connect naming method. Did you specify like NAMES.DIRECTORY_PATH=(tnsnames, ezconnect)
in your sqlnet.ora
file?