Start New Discussion within our Software Development Community

My tnsNames.Ora File -

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Sonia-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ORACLR_CONNECTION_DATA = 
  (DESCRIPTION = 
    (ADDRESS_LIST = 
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) 
    ) 
    (CONNECT_DATA = 
      (SID = CLRExtProc) 
      (PRESENTATION = RO) 
    ) 
  ) 

.Net Code -

public partial class Default2 : System.Web.UI.Page
{

    OracleCommand cmd = new OracleCommand();
    OracleConnection conn = new OracleConnection("Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = Sonia-PC)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE))),UserID=user_test,Password=sonia;");

    protected void Page_Load(object sender, EventArgs e)
    {
        cmd.CommandText = "INSERTSTUDENT";
        cmd.Connection = conn;
        cmd.Parameters.Add("p_roll", OracleDbType.Long, 64, 1, ParameterDirection.Input);
        cmd.Parameters.Add("p_name", OracleDbType.Varchar2, 2000, "sonia", ParameterDirection.Input);
        cmd.Parameters.Add("p_marks", OracleDbType.Long, 64, "10", ParameterDirection.Input);
        conn.Open();
        cmd.ExecuteNonQuery();
    }
}
`

When the line conn.Open() is executed ERROR is dere -** *ORA-12154: TNS:could not resolve the connect identifier specified* ** My SQL Developer is connected with ORACLE. There is no error in Oracle Set Up.

I have set Data Source = XE also but it also giving the same ERROR.``

I think this link can help you

Because on the tnsNames.ora file you already have an XE entry, maybe you only need to declare the connection string as
"Data Source=XE,UserID=user_test,Password=sonia;"

Hope this helps.

This article has been dead for over six months. Start a new discussion instead.