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?

更多推荐