开发者

ODP.NET doesn't work System.Data.OracleClient does

开发者 https://www.devze.com 2023-04-10 00:26 出处:网络
We are switching from the obsolete System.Data.OracleClient. I have switched all the references in the ASP.NET 2.0 code, however when I try to access the database server using ODP.NET calls I get ORA-

We are switching from the obsolete System.Data.OracleClient. I have switched all the references in the ASP.NET 2.0 code, however when I try to access the database server using ODP.NET calls I get ORA-12154: TNS:could not resolve the connect i开发者_运维百科dentifier specified. This works when I use System.Data.OracleClient on the same machine. Any suggestions about what is going wrong here?


You can avoid a dependency on Tnsnames.ora altogether, and go for the "independent" connection string in format:

Data Source =(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID))); User Id =myUsername; Password =myPassword;

BTW, you can look at connectionstrings.com/oracle for a quick, in-your-face list of supported connection string formats.


It sounds like your client install doesn't have your TNS names setup correctly. If you just installed ODP.NET on this machine, you probably just installed another Oracle client, and have yet to configure it.


Copy the TNSNAMES.ORA from the /NETWORK/ADMIN directory in the Oracle home where the OracleClient was installed and copy over to the new /NETWORK/ADMIN directory where ODP.NET is installed.

http://www.oracle.com/technetwork/topics/dotnet/odt-faq-085407.html#ORA-12154:_TNS:could_not_resolve_the

Christian Shay

Oracle

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号