Error ORA-12154 in Delphi for a connection that's working in TOAD
In Delphi 2010 I want to connect to a Oracle XE instance installed in my own machine using the ODAC components (TOraSession). When I set the parameters for the connection I got the "ORA-12154: TNS: could not resolve the connect identifier specified" error message.
However using the same parameters (and the same TNSNames.Ora file)开发者_JAVA技巧 I can connect using TOAD.
Can anybody help me with this.
Thanks in advance
If you're running on a x64 OS and you have Delphi (or any software trying to access Oracle) installed in a path with parentheses (i.e (x86)...) while TOAD is not, you may encounter this error.
See DocID 334528.1 in Oracle Support (if you have access). This bug has been fixed in a later patch, but no official patch is available for XE (which basically is a 10.2.0.1).
I would not use Oracle XE because it is pratically an unsupported version, no patch are released for it. I you need Oracle for self-learning you can download the full software at http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html (check the license), if you need a free database server look elsewhere.
Could be that you are not using the same tnsnames.ora (even though you think you do). This can happen if you have for instance the Oracle 10g client installed and ODAC 11.
To see if this is a tnsnames issue you can try to connect without tnsnames from code like this:
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=[MyHost])(PORT=[MyPort])))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=[MyOracleSID])));User Id=[myUsername];Password=[myPassword];
replacing the values between [] with your actual values so (HOST=128.1.7.9)(PORT=1521)....
精彩评论