Reputation: 2832
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
Upvotes: 1
Views: 3857
Reputation: 41
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
.
Upvotes: 1
Reputation: 10565
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.
Upvotes: 1
Reputation: 1625
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
Upvotes: 1