.net 使用 Microsoft ODBC for Oracle 连接到 Oracle 10g 数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/782181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 12:34:25  来源:igfitidea点击:

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

.netoracleoracle10godbcora-12514

提问by Gaidin

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.

我正在尝试使用内置的 Microsoft ODBC for Oracle 驱动程序连接到 Oracle 10g 数据库。我想使用 dnsless 连接,所以我从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:

理想情况下,我不必设置 DNS 条目或 Oracle TNS 条目,我可能会弄错,但我认为上面的内容可以为我做这些。我得到以下信息:

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.

据我在线所知,其他人已经使用 Microsoft ODBC for Oracle 驱动程序连接到 10g,但也许我遗漏了一些东西。顺便说一下,我是从 vb.net 应用程序连接的。

采纳答案by Gaidin

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;

回答by Mac

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

使用 10g,您可以使用EZCONNECT功能。要连接到服务器 myServer 上名为 ORCL 的 Oracle 实例,连接字符串将如下所示:

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

回答by JosephStyons

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

您需要在 tnsnames.ora 文件中为要连接的服务添加一个条目。或者,您可以转到该文件的 gui 界面

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.

并在那里设置您的 oracle 连接。然后,ODBC 将能够解析服务名称。