Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use ODBC SQLDriverConnect() without using tnsnames.ora file

user552098Jan 8 2007 — edited Jan 9 2007
I have an ODBC application that connects to an Oracle 10g database. Currently, my SQLDriverConnect() function call uses the following connection string:

DRIVER={Oracle in OraClient10g_home1}; DBQ=MyDB.world; DBA=W; UID=foo; PWD=bar

This requires an entry in the tnsnames.ora file that looks like this:

MyDB.world =
(DESCRIPTION = (ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)(Host = server1.intel.com)(Port = 1521)
)
(ADDRESS =
(PROTOCOL = TCP)(Host = server2.intel.com)(Port = 1521)
)
(ADDRESS =
(PROTOCOL = TCP)(Host = server3.intel.com)(Port = 1521)
)
(ADDRESS =
(PROTOCOL = TCP)(Host = server4.intel.com)(Port = 1521)
)
)
(LOAD_BALANCE = yes)
(CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = MY_SRVC))
)

However, I would really like to be able to connect using ODBC without having to create that entry in the tnsnames.ora file. I have tried to substitute the DBQ=MyDB.world with the entire (DESCRIPTION=..... string from the original tnsnames.ora file, but it returns the error:

ORA-12154: TNS: Could not resolve the connect identifier specified.

I have heard others are able to use sqlplus with no tnsnames.ora file and the do specify the entire (DESCRIPTION=.... string on the sqlplus connection string, but is this possible to do using the ODBC SQLDriverConnect() function? If so, do I need to use a different keyword/value pair other than DBQ=?

Any help on this would be greatly appreciated.

Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2007
Added on Jan 8 2007
3 comments
1,300 views