Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi there,

I have a webapp, VS2013, C# and ASP.NET, and I use Oracle 12c as DB, so when I try to connect to DB from my webapp I got this error: ORA-12541: TNS:no listener, this is my code:

C#
public bool OpenConnection(Label lbl)
       {
           try
           {
               using (cn = new OracleConnection(WebConfigurationManager.ConnectionStrings["RegistroConnection"].ToString()))
               {
                   if (cn.State == ConnectionState.Closed)
                   {
                       cn.Open();
                   }
               }
               return true;
           }
           catch (NullReferenceException nullExcept)
           {
               lbl.Text =  "Caught error: ." + nullExcept.ToString();
               return false;
           }
           catch (OracleException dbEx)
           {
               lbl.Text = "OraException - " + dbEx.Message;
               return false;
           }
           catch (Exception ex)
           {
               Exception current;
               current = ex;

               while (current != null)
               {
                   current = current.InnerException;
               }

               lbl.Text = "Db base exception - " + ex.GetBaseException().ToString();
               return false;
           }
       }


I have the connectionstring on my webconfig:

HTML
<connectionStrings>
    <add name="RegistroConnection"
    connectionString="Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =myServer)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SID = sidname)));User Id=user;Password=password;"
    providerName="Oracle.DataAccess.Client"/>
  </connectionStrings>


the dll already added is:
- Oracle.DataAccess.Client

If i try to connect through Sql Developer I have a successful connection but on my webapp I have this error: ORA-12541: TNS:no listener

Please, somebody help me

I'll waiting for your response!

Thanks and Regards.
Posted

1 solution

 
Share this answer
 
Comments
Elmer A. Chacon 10-Mar-15 16:37pm    
Is not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900