There are no possibility to connect using Oracle ODBC driver without TNS alias already configured in tnsnames.ora file.
All configuration steps mentioned in Oracle ODBC Driver documentation requires it:
- Connecting to DataSource
- Configuring theDataSource
- Oracle ODBC Driver Configuration Dialog Box
Also in documentation for SQLDriverConnect implementation DBQ parameter noted as required, and passing a name of TNS alias in this parameter is only method to specify server to connect to.
Because it's a common API function used by all clients of Oracle ODBC Driver, there are no possibility that some other interface (COM-object, configuration dialog or something else) may accept different parameters for connection.
There are no such possibility in Oracle Objects for OLE too.
I can't find anything about cancelling of Oracle Provider for OLEDB support.
It has been released as a part of latest version of ODAC: "ODAC 12c Release 4 (12.1.0.2.4)" and this release is a top news topic at related section of Oracle site at the moment.
There are some improvements in latest versions and support for usage from .NET applications.
Also, it works (at least for me):
Const hostName = "server_host"
Const portNo = "1521"
Const srvSID = "ORASERVERSID"
Const usrID = "login"
Const usrPwd = "password"
Sub con_Oracle_OLEDB()
strDriver = "Provider=OraOLEDB.Oracle;"
strParams = "Data Source=(DESCRIPTION=(CID=MyVbaApp)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + hostName + ")(PORT=" + portNo + ")))(CONNECT_DATA=(SID=" + srvSID + ")));"
strCon = strDriver + strParams + strUser
' Open the above connection string.
Dim con As Object
Set con = CreateObject("ADODB.Connection")
con.ConnectionString = strCon
con.Open
End Sub
Based on the above, I recommend to stay with OLEDB Provider, just update ODAC to a latest version.
If you don't want to use OLEDB at all, there are a variant with Microsoft ODBC driver("Driver={Microsoft ODBC for Oracle};") with detailed server parameters specification in CONNECTSTRING:
Const hostName = "server_host"
Const portNo = "1521"
Const srvSID = "ORASERVERSID"
Const usrID = "login"
Const usrPwd = "password"
Sub con_Microsoft_ODBC_for_Oracle()
strDriver = "Driver={Microsoft ODBC for Oracle};"
strParams = "CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + hostName + ")(PORT=" + portNo + "))(CONNECT_DATA=(SID=" + srvSID + ")));"
strUser = "UID=" + usrID + ";PWD=" + usrPwd + ";"
strCon = strDriver + strParams + strUser
' Open the above connection string.
Dim con As Object
Set con = CreateObject("ADODB.Connection")
con.ConnectionString = strCon
con.Open
End Sub
Of course, this variant has its own drawbacks. At least, there are a much more probability of support cancellation from Microsoft's side than from side of Oracle.