Connect to an Oracle 10g database with Microsoft ODBC for Oracle

筅森魡賤 提交于 2019-11-28 01:22:38

问题


I'm trying to connect to an Oracle 10g database using the built in Microsoft ODBC for Oracle driver. I want to use an dnsless connection, so I grab my connection string from www.connectionstrings.com.

Ideally I won't have to setup a DNS entry or an Oracle TNS entry, and I may be mistaken, but I thought the above would do that for me. I'm getting the following:

ERROR [NA000] [Microsoft][ODBC driver for Oracle][Oracle]ORA-12514:
TNS:listener does not currently know of service requested in connect
descriptor

ERROR [IM006] [Microsoft][ODBC Driver Manager]
Driver's SQLSetConnectAttr failed

ERROR [01000] [Microsoft][ODBC Driver Manager] 
The driver doesn't support the version of ODBC behavior that the
application requested (see SQLSetEnvAttr)."

As far as I can tell online, other people have used the Microsoft ODBC for Oracle driver to connect to 10g, but maybe I'm missing something. I'm connecting from a vb.net application by the way.


回答1:


With 10g, you can use the EZCONNECT feature. To connect to an Oracle instance named ORCL on the server myServer, the connection string would look like this :

Driver={Microsoft ODBC for Oracle};Server=myServer:1521/ORCL;Uid=myUsername;Pwd=myPassword;



回答2:


I'm not sure how kosher it is to answer your own question, but I found a connection string that is more what I'm looking for:

"Driver={Microsoft ODBC for Oracle}; " & _
                                 "CONNECTSTRING=(DESCRIPTION=" & _
                                 "(ADDRESS=(PROTOCOL=TCP)" & _
                                 "(HOST=myserver)(PORT=1521))" & _
                                 "(CONNECT_DATA=(SERVICE_NAME=servicename))); " & _
                                 "uid=username;pwd=password;



回答3:


You need to add an entry in your tnsnames.ora file for the service to which you want to connect. Alternatively, you can go to the gui interface for that file at

Start->Programs->Oracle->Configuration and Migration Tools->Net Configuration Assistant

and set up your oracle connection there. Then, ODBC will be able to resolve the service name.



来源:https://stackoverflow.com/questions/782181/connect-to-an-oracle-10g-database-with-microsoft-odbc-for-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!