Initially I was using oraoledb.oracle provider in order to connect to Oracle database and it was easy to build a connection string:
Provider=OraOLEDB.Oracle;User Id=myId;Password=myPassword;Data Source=data.customer.com
and everything works as it expected, but currently I switched to ODP.Net in order to get rid of installing oracle client and I get an error ORA-12154: TNS:could not resolve the connect identifier specified with the following connection string:
Data Source=data.customer.com;User Id=myId;Password=myPassword
So could someone tell me, where I made a mistake?
Personally, I prefer not to depend on defined tnsnames.ora on a machine. Using longer connection string(see example below) you could deploy your program not thinking about tnsnames.ora that may not exist on a target system.
Example of using ODP.NET without tnsnames.ora:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));
User Id=myUsername;Password=myPassword;
See also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With