1

I have a frustrating error. I'm connecting to Oracle (or trying to) from both a Winforms app and Asp.net page.
Winforms - no problem, Asp.Net - lots of problems.

Error I'm getting (running from IIS) is:

ORA-12545: Connect failed because target host or object does not exist

To me it this message might indicate that either my connection string is wrong or that Oracle is off, or firewall issues, but I'm using the same connection string and code that is working from Winforms on the same machine.

Any idea other ideas what might cause this error?

Code that fails:

string conn = "User Id=172.xx.xx.xxx ;Password=xxx;Data Source=(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=xx)(PORT=1521)) (CONNECT_DATA=(SID=xxx))); 
OracleConnection oc = new OracleConnection(conn);

EDIT:
Full Stack:

ORA-12545: Connect failed because target host or object does not exist 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

     Exception Details: Oracle.DataAccess.Client.OracleException: ORA-12545: Connect failed because target host or object does not exist

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 



[OracleException (0x80004005): ORA-12545: Connect failed because target host or object does not exist]
   Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) +1563
   Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +59
   Oracle.DataAccess.Client.OracleConnection.Open() +4899
   UDWWeb.Pages.Availability.Button1_Click(Object sender, EventArgs e) +49
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
1
  • Show your stack trace Commented Sep 20, 2013 at 8:27

3 Answers 3

1

First, perform the below checks:

1.) making sure that your listener is running (lsnrcrl stat)
2.) testing connectivity with ping, and then tnsping.
3.) verifying connectivity via the DNS (e.g. /etc/hosts)
4.) make sure to check your tnsnames.ora parms.

Ensure the ADDRESS parameters have been entered correctly; the most likely incorrect parameter is the node name. Ensure that the executable for the server exists. If the protocol is TCP/IP, edit the TNSNAMES.ORA file to change the host name to a numeric IP address and try again.

Lastly, Check once again your ConnectionString. For example when using asp.net it is of Format as shown below.( Web.config example )

<add name="OracleConnectionString"
  connectionString="Data Source=OracleServer1;Persist 
    Security Info=True;Password="******";User ID=User1"
  providerName="System.Data.OracleClient" /> 

Check this detailed explanation.

Sign up to request clarification or add additional context in comments.

2 Comments

I do not have access to the Oracle server, but if any of these suggestions are at fault, then surely my connection from the Winforms app would have failed as well?
Check once again the address parameter in your Connection strings also.
1

Instead of giving Tns like that in Data Source. Put it into (Oracle Client Folder) -> product-> network -> admin -> tnsnames.ora file.

Then you can use OleDbConnection like an Sql datasource. In example:

Provider=OraOLEDB.Oracle.1;Password=***;Persist Security Info=True;User ID=***;Data Source=DataSource_Name_in_TNS_File

2 Comments

Although not a bad idea, the down side is that I have to deploy the Oracle client to all the servers where this will be deployed. I will however try this.
I am also having similar kind of issue on local the connection is works fine with oracle node driver but when i deploy on docker node image then its failed with same error..... any idea?
1

I was also having same issue, the application was running on my local PC, but when I uploaded it on server I was the getting same error.

I resolved it simply by writing full host name in my connection string, for example host=abcd.exchange.com. Don't write a short name like host=abcd.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.