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數據庫。我想使用無連接的連接,所以我從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應用程序連接的。
3 个解决方案
#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 :
使用10g,您可以使用EZCONNECT功能。要連接到服務器myServer上名為ORCL的Oracle實例,連接字符串將如下所示:
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
您需要在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將能夠解析服務名稱。