Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a Sharepoint 2010 .NET 3.5 system running on my local Windows 7 machine with IIS. I have been unable to connect to our corporate Oracle database via Oracle.DataAccess.dll. The error message I get in my .NET webapp (sharepoint) is "ORA-12154: TNS: could not resolve the connect identifier specified".

Here's the good news:

  • I can connect to this DB fine with TOAD, from my same PC.
  • Our TEST server can connect fine to the DB through sharepoint/.net and everything.

So it feels like I'm very close and just need to tweak something. A bunch of articles I read say to cut out the TNS/ora file and go straight from .net to the DB by constructing a .net connection string thusly:

connString="user id=usridname;password=yourpassword;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostnamehere)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=servicenamehere)));"

I would love to use this approach. I have the username and password, but I don't know how to discover the other parts. It's probably a simple thing to discover the hostname, port, and servicename by examining my TOAD connection, or by peeking in some file on the TEST server that works. But I have no idea where to look, either in toad, or on the test server where it works. I have full remote desktop admin access to the test server, so I can look at anything.

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to locate your tnsnames.ora file and check the entries.

Run tnsping from the command line of the server you are running with the name of the connection you connect to with toad.

> tnsping haki

TNS Ping Utility for 32-bit Windows: Version 10.2.0.3.0 - Production on 16-JUN-2013 14:14:10

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:
C:\oracle\product\10.2.0\db_3\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = *****)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = haki))) 
OK (0 msec)

Look for a file called tnsadmin.ora under the network parameter directory. as you can see, in my case it's C:\oracle\product\10.2.0\db_3\network\admin\.

If this dosent work or you located the file but the entry wasn't there try running netca and create an entry using the wizard.

sometimes people install more then one client software and there a whole mess with the PATH.

share|improve this answer
    
The best solution was to do a tnsping and then grab the values to construct the connection string with: connString="user id=usridname;password=yourpassword;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostnamehere)(PORT=1521))(CONNE‌​CT_DATA=(SERVICE_NAME=servicenamehere)));" –  SweatCoder Jun 17 '13 at 21:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.